Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 it

Cognitive Complexity Analysis

java -jar cognitive-analysis.jar analyse ".\\src\\main\\java\\"

Documentation

Resources

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

Example

File: C:\Users\florian\Desktop\Java\cognitive-code-analysis\.\src\main\java\net\floriankraemer\cognitive_analysis\domain\ScoreCalculator.java

┌───────────────┬──────────────────┬─────┬─────┬──────────┬─────┬─────┬──────┬──────┬──────┬────────┬─────────┬──────────┐
│Class          │Method            │Line │ If  │If-Nesting│Else │Loop │Switch│Method│Return│Argument│Try-Catch│Complexity│
│               │                  │Count│Count│  Level   │Count│Count│Count │ Call │Count │ Count  │ Nesting │          │
│               │                  │     │     │          │     │     │      │Count │      │        │  Level  │          │
├───────────────┼──────────────────┼─────┼─────┼──────────┼─────┼─────┼──────┼──────┼──────┼────────┼─────────┼──────────┤
│ScoreCalculator│calculateScore    │ 55  │  0  │    0     │  0  │  0  │  0   │  50  │  0   │   1    │    0    │0,875     │
├───────────────┼──────────────────┼─────┼─────┼──────────┼─────┼─────┼──────┼──────┼──────┼────────┼─────────┼──────────┤
│ScoreCalculator│getThreshold      │  3  │  0  │    0     │  0  │  0  │  0   │  0   │  1   │   0    │    0    │0,000     │
├───────────────┼──────────────────┼─────┼─────┼──────────┼─────┼─────┼──────┼──────┼──────┼────────┼─────────┼──────────┤
│ScoreCalculator│getScale          │  3  │  0  │    0     │  0  │  0  │  0   │  0   │  1   │   0    │    0    │0,000     │
├───────────────┼──────────────────┼─────┼─────┼──────────┼─────┼─────┼──────┼──────┼──────┼────────┼─────────┼──────────┤
│MetricConfig   │getThreshold      │  3  │  0  │    0     │  0  │  0  │  0   │  0   │  1   │   0    │    0    │0,000     │
├───────────────┼──────────────────┼─────┼─────┼──────────┼─────┼─────┼──────┼──────┼──────┼────────┼─────────┼──────────┤
│MetricConfig   │getScale          │  3  │  0  │    0     │  0  │  0  │  0   │  0   │  1   │   0    │    0    │0,000     │
├───────────────┼──────────────────┼─────┼─────┼──────────┼─────┼─────┼──────┼──────┼──────┼────────┼─────────┼──────────┤
│ScoreCalculator│calculate         │ 25  │  1  │    1     │  0  │  0  │  0   │  10  │  0   │   2    │    0    │0,182     │
├───────────────┼──────────────────┼─────┼─────┼──────────┼─────┼─────┼──────┼──────┼──────┼────────┼─────────┼──────────┤
│ScoreCalculator│calculateLogWeight│  6  │  1  │    1     │  0  │  0  │  0   │  1   │  3   │   3    │    0    │0,182     │
└───────────────┴──────────────────┴─────┴─────┴──────────┴─────┴─────┴──────┴──────┴──────┴────────┴─────────┴──────────┘

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.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages