Code quality done right
Code Health
a Metric You Can Trust
CodeScene's Code Health metric is the software industry's only code-level metric with proven business impact, measured through fact-based, winning research. It's a metric that you can trust. Know when and how to improve existing code in order to keep the system maintainable.
Why choose Code Health as your Quality Metric?
Code-Level Metric Backed by Research
Code Health is the only code-level metric in our industry with a proven link to speed and quality. Code Health is evidence-based and the effectiveness of the metric was evaluated in the Code Red paper.
Integrate in Development Process
Integrate local quality gates with CodeScene's CLI tool and IDE extension. Only merge high quality code and prevent any code health declines.
Actionable via Automated Code Reviews
CodeScene's Pull Request integration allows you to detect code quality issues via automated code reviews. Developers get detailed explanations of issues and recommendations. One-click, seamless integration with GitHub, BitBucket, Azure DevOps, and GitLab.
Quality Dimension for Identifying Technical Debt and Refactoring Targets
When combining Hotspots with CodeScene’s Code Health Perspective, you can quickly prioritize technical debt or other code quality issues, and find refactoring candidates.
Code Health is an aggregated metric based on 25+ factors scanned from the source code. The code health factors correlate with increased maintenance costs and an increased risk for defects. Code Health is a model that correlates measurable aspects of your code with positive or negative outcomes for your project.
Each file with source code is categorized as either:
Green (healthy code that’s easy to change)Yellow (complex code with maintenance issues and increased defect risk)
Red (code with a severe technical debt and maintainability challenges)
Module Smells
- Low Cohesion
Multiple unrelated responsibilities in a module/class, violating the Single Responsibility Principle (measured by LCOM4). - Brain Class (God Class)
Large module with many lines of code, numerous functions, and at least one complex central method. - Developer Congestion
Bottlenecks when multiple developers work on the same code. - Complex Code by Former Contributors
If a developer behind a hotspot with low Code Health leaves the organization, the maintenance risk increases significantly.
Function Smells
- Brain Method (God Function)
Complex function centralizing behavior, becoming a local hotspot. - DRY (Don't Repeat Yourself) Violations
Duplicated logic changed together predictably. - Complex Method
Many conditional statements (e.g., if, for, while) reduce code health (cyclomatic complexity). - Primitive Obsession
Overuse of built-in primitives without encapsulation. - Large Method
Functions with many lines of code are harder to understand.
Implementation Smells
- Nested Complexity
If-statements or loops inside others increase defect risk. - Bumpy Road
Functions with multiple logical chunks; needed for encapsulation into smaller functions. - Complex Conditional
Expression with multiple logical operators (AND/OR) inside branches complicate understanding. - Large Assertion Blocks
Consecutive assert statements indicate missing abstractions. - Duplicated Assertion Blocks
Copy-pasted assertion blocks in tests indicate DRY violations.
Why is Code Health the industry-leading code-quality Metric?
Supported by acclaimed research
Code Health is evidence-based and the effectiveness of the metric is evaluated in the Code Red paper. This quantitative study of 39 proprietary production codebases from various industries and domains shows that a healthy codebase enables a faster time-to-market while minimizing rework.
15x fewer bugs
Healthy code has 15x fewer bugs
2x faster development
With healthy code, you can double the speed of your feature delivery
9x lower uncertainty
With healthy code, it's nine times more likely that features will be delivered on time
Is Code Health a better metric than SonarQube?
A recent benchmark study compared CodeScene's Code Health metric to SonarQube. The study clearly indicates that Code Health is the better choice.
The Code Health metric outperforms SonarQube in maintainability ratings
Benchmarking of SonarQube and CodeScene on public software maintainability datasets shows that CodeScene's Code Health metric is 6x more accurate, performing at the level of expert human developers.
Software maintainability is the most important metric. Developers need to maintain the code
Software maintenance accounts for more than 90% of a software product’s lifecycle costs. Developers spend 70% of their time on understanding existing code.
Public benchmarking dataset to compare code quality metrics
For the benchmark study a public and independent software maintainability dataset was used. The dataset includes 1.4 million lines of manually reviewed code to establish a ground truth for code quality. The results from SonarQube and CodeScene were then compared to this dataset.
CodeScene includes behavioral data
Code quality issues can't be prioritized from code alone
Many organizations struggle with technical debt and code quality issues. How do we know what we shall prioritize? While traditional code analysis tools are good for the details, they simply weren’t intended to prioritize technical debt; getting a list of 3,000 major issues won’t help anyone.
CodeScene was developed to address these challenges by automatically prioritizing technical debt based on development hotspots. Using hotspots, you can detect an overlap between complex code and high levels of development activity.
That’s code where paying down debt has a real impact. The Code Health metric was designed to complement hotspots by providing that assessment in an automated and reliable way.
“I would recommend CodeScene, especially to someone who is coming into a really large application and has poor code health. It feels really daunting to try to fix everything at once. CodeScene helps you prioritize what files to work on and which ones will have the most impact if you are to improve code quality.”
Lauren Swansson
- Lead Software Engineer at Carterra
Follow your Code Health Progress and Identify Risks
Main KPIs for your Code Health
A single KPI isn’t enough to capture the multi-facetted aspect of code health in a larger codebase
CodeScene presents three separate metrics to create a unique code health profile of your codebase. The three KPIs together give you a representative view of your code health. CodeScene weights and scores the findings according to an extensive set of baseline data from real-world codebases to come up with the normalized code health metric.
The hotspots could be healthy, but other parts of the code have severe issues
Averages are tricky since they might hide low-scoring files that represent a risk
Or maybe you have a problematic legacy module that is relatively stable but could be a long-term risk?
A weighted average of the Code Health in your hotspots. Generally, this is the most critical metric since low Code Health in a hotspot will be expensive.
A weighted average of all the files in the codebase. This KPI indicates how deep any potential Code Health issues go.
A single file Code Health score representing the lowest Code Health in any module across the codebase, and it points out long-term risks.
Follow your Code Health Progress and Identify Risks
Adapt Code Health to Your Coding Standards
CodeScene’s code health rules are fine-tuned using real-world codebases, making the default rules highly effective in predicting maintenance and delivery risks. We also recognize the importance of giving users control over these rules. There are two customization options available:
-
Code Health Directives: These are source code comments that instruct CodeScene to ignore specific code smells. Directives offer granular control at the function level. For more details, see Disable Local Smells via Code Comment Directives.
-
JSON Configuration: You can modify the code health rules for entire repositories, folders, or files by providing a JSON file with your custom settings. For more information, see Customize the Code Health Rules via JSON.
Trends are actionable
When analyzing code, prioritize trends over absolute values - is the situation getting better or worse?
Using CodeScene's high-level dashboards with Code Health KPIs, you can track progress over time, monitor your code health, see where you've started to degrade in code quality, and include this information in your retrospectives. What parts of the codebase are getting better or worse?
Where do you need to focus, and what parts of the codebase are starting to become too hard to work with and too expensive to maintain?
Trends are actionable
When analyzing code, prioritize trends over absolute values - is the situation getting better or worse?
Using CodeScene's high-level dashboards with Code Health KPIs, you can track progress over time, monitor your code health, see where you've started to degrade in code quality, and include this information in your retrospectives. What parts of the codebase are getting better or worse?
Where do you need to focus, and what parts of the codebase are starting to become too hard to work with and too expensive to maintain?