Skip to content

Latest commit

 

History

History
64 lines (43 loc) · 3.27 KB

File metadata and controls

64 lines (43 loc) · 3.27 KB

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.