SpecThis logo

Code Complexity Metrics Overview

Understanding the metrics Spec This uses to measure code complexity and quality

Spec This analyzes your codebase and measures various complexity metrics to help you identify problematic code early. These metrics are based on industry-standard measures of code quality and maintainability.

How to Use This Documentation

Each metric has its own dedicated page with:

  • Detailed explanation of what the metric measures
  • Step-by-step calculation methodology
  • Real code examples showing good and bad practices
  • Recommended thresholds for different sensitivity levels
  • Practical refactoring strategies

Metric Categories

Configuring Alerts

Setting Thresholds

You can configure alert thresholds in your Organization Settings. Spec This provides three preset sensitivity levels:

  • High Sensitivity: Strict thresholds for critical code or high-quality standards
  • Medium Sensitivity: Balanced thresholds suitable for most production code
  • Low Sensitivity: Relaxed thresholds for legacy code or gradual improvement

You can also set custom thresholds for each metric individually to match your team's coding standards.

Best Practices

Using Metrics Effectively

  • Start with medium sensitivity and adjust based on your team's needs and codebase maturity
  • Use alerts as guidelines, not absolute rules - context and business requirements matter
  • Focus on trends over time rather than fixing every alert immediately
  • Review alerts during code reviews to prevent complexity from growing
  • Consider the criticality of the code when evaluating alerts (e.g., security-critical code should have lower thresholds)
  • Use refactoring strategies from the detailed metric pages to address high-complexity code
  • Track improvements by monitoring how your metrics change over time

Understanding Alert Severity

🔴 Critical

Metric value significantly exceeds threshold (200%+). Immediate attention recommended.

🟡 Warning

Metric value moderately exceeds threshold (120-200%). Should be addressed soon.

🔵 Info

Metric value slightly exceeds threshold (100-120%). Worth monitoring.

Ready to Dive Deeper?

Click on any metric in the sidebar or above to learn:

  • Detailed calculation methodology with step-by-step examples
  • Real code examples showing what to avoid and how to improve
  • Practical refactoring strategies you can apply immediately
  • Industry best practices and recommended thresholds