Skip to content

A Cognitive Code Complexity Analysis Tool. Cognitive complexity measures how hard it is for a human to understand the code, while cyclomatic complexity measures how hard your code is to test. Understandability is a huge cost factor because ~80% time is spent on reading and understanding code.

License

Notifications You must be signed in to change notification settings

floriankraemer/cognitive-code-analysis-csharp

Repository files navigation

Cognitive Complexity Analysis

Cognitive Code Analysis is an approach to understanding and improving code by focusing on how human cognition interacts with code. It emphasizes making code more readable, understandable, and maintainable by considering the cognitive processes of the developers who write and work with the code.

"Human short-term or working memory was estimated to be limited to 7 ± 2 variables in the 1950s. A more current estimate is 4 ± 1 constructs. Decision quality generally becomes degraded once this limit of four constructs is exceeded."

Source: Human Cognitive Limitations. Broad, Consistent, Clinical Application of Physiological Principles Will Require Decision Support

Running the Analysis 🧑‍💻

The tool analyses C# files and generates cognitive complexity reports. Run the analysis using:

CognitiveCodeAnalysis [sourcePath] [options]

Arguments:

  • [searchPath] - (Optional) Path to search for C# files. Defaults to the current directory.

Options:

  • -c|--config <path> - Load a custom configuration file
  • -r|--report-type <type> - Report type: ConsoleText (default) or Html
  • -o|--output-file <path> - Output file path (defaults to cognitive-analysis-report)

Examples:

# Analyse current directory with console output
CognitiveCodeAnalysis

# Analyse a specific directory
CognitiveCodeAnalysis ./src

# Generate an HTML report
CognitiveCodeAnalysis ./src -r Html -o report.html

# Use a custom configuration file
CognitiveCodeAnalysis ./src -c my-config.json

Resources 🔗

These pages and papers provide more information on cognitive limitations and readability and the impact on the business.

License ⚖️

Copyright Florian Krämer

Licensed under the GPL3 license.

About

A Cognitive Code Complexity Analysis Tool. Cognitive complexity measures how hard it is for a human to understand the code, while cyclomatic complexity measures how hard your code is to test. Understandability is a huge cost factor because ~80% time is spent on reading and understanding code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages