<img src="https://secure.leadforensics.com/794635.png" style="display:none;">
Skip to content

CodeHealth™ - the metric you can trust

CodeScene's Code Health is the only code-level metric with proven business impact, backed by winning, fact-based research. Know when and how to improve code to keep your system maintainable.

Why choose Code Health as your quality metric?

counter_1_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24

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.

View Code Red paper
counter_2_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24

Local quality gates during the 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.

counter_3_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24

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.

counter_4_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24

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.

"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."
Read full Carterra case study
feature-ch-kpi-1

How is Code Health calculated?

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.

How we classify code

Each file is categorized either as:

  • Green code, healthy code that’s easy to change
  • Yellow code, complex code with maintenance issues and increased defect risk
  • Red code, code with a severe technical debt and maintainability challenges)
feature-codehealth-1
counter_1_24dp_172E52_FILL0_wght400_GRAD0_opsz24

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.

counter_2_24dp_172E52_FILL0_wght400_GRAD0_opsz24

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.

counter_3_24dp_172E52_FILL0_wght400_GRAD0_opsz24

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.

What's a good Code Health score?

The Code Health scale goes from 1 to 10. Ten indicates very maintainable code. Moving from 6.0 to 8.0 would mean a quite dramatic improvement on time in development. This means your team can iterate 30% faster, on average, on your coding tasks.

feature-ch-scale

Supported by acclaimed research

CodeHealth™ 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.

Ship healthier code and prevent up to 15x more defects before they happen

15x

Fewer bugs

Speed up delivery by 2x by addressing productivity bottlenecks

2x

Faster feature delivery

Reduce delivery risks by 9x with better Code Health

9x

More likely to deliver on time

Is Code Health a better metric than SonarQube?

A recent benchmark study compared CodeScene’s CodeHealth™ metric to SonarQube’s found that CodeHealth is 6x more accurate, performing at the level of expert human developers.

feature-sonarqube-comparison (1)
counter_1_24dp_172E52_FILL0_wght400_GRAD0_opsz24

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.

counter_2_24dp_172E52_FILL0_wght400_GRAD0_opsz24

Software maintainability is the most important metric

Software maintenance accounts for more than 90% of a software product’s lifecycle costs. Developers spend 70% of their time on understanding existing code.

counter_3_24dp_172E52_FILL0_wght400_GRAD0_opsz24

Public benchmarking dataset to compare code quality metrics

For the benchmark study, a public and independent software maintainability dataset was used, containing 1.4 million lines of manually reviewed code as a ground truth for code quality. SonarQube and CodeScene results were then compared to this dataset.

Code quality issues can't be prioritized from code alone

Not all code is equally important, and not all technical debt is bad. Traditional code analysis tools are good at surface-level details, but they weren’t built to prioritize technical debt, being overwhelmed with 3,000 issues doesn’t help anyone.

CodeScene stands out by prioritizing technical debt based on how your team actually works with the code, not just how the code looks. By combining Code Health metrics with development hotspots, CodeScene pinpoints the parts of your system where poor code quality actively slows your team down. These are the areas that matter most, where refactoring delivers the biggest impact.

feature-codehealth-hotspots
feature-platform-nxt

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?
Hotspot Code Health

Hotspot code health

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.

Average Code Health

Average code health

A weighted average of all the files in the codebase. This KPI indicates how deep any potential Code Health issues go.

Worst performer

Worst performer

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

code-health-goals-2

Trends are actionable

When analyzing code, prioritize trends over absolute values. Is the situation getting better or worse? With CodeScene’s high-level dashboards and Code Health KPIs, you can track progress over time, monitor trends, identify areas where code quality is degrading, and bring those insights into retrospectives.

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:

counter_1_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24

Code Health directives

These are source code comments that instruct CodeScene to ignore specific code smells. Directives offer granular control at the function level.

See disable local smells via code comment directives
counter_2_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24

JSON configuration

You can modify the code health rules for entire repositories, folders, or files by providing a JSON file with your custom settings.

See customize the Code Health rules via JSON

Broad language support for smarter code analysis

CodeScene delivers deep insights across 30+ programming languages to keep your code maintainable and high-performing.

programming-languages-1

Understanding Code Health and code complexity

In this tutorial, we discuss our Code Health metric and the reasoning behind it and why it's important.

Take control of your
technical debt today

Don’t let technical debt slow down your development process. Ready to assess your Code Health?