Cyclomatic Complexity Calculator
Calculate McCabe cyclomatic complexity from edges, nodes, and connected components. Classify code complexity and risk levels.
Calculate LOC, SLOC, blank lines, comment lines, and comment ratio for your codebase. Analyze code composition metrics.
| Size Class | SLOC Range | Typical Effort | Example |
|---|---|---|---|
| Tiny | < 1,000 | < 1 person-month | Script, utility |
| Small | 1,000 โ 10,000 | 1 โ 6 person-months | CLI tool, small app |
| Medium | 10,000 โ 100,000 | 6 โ 24 person-months | Web app, API service |
| Large | 100,000 โ 1,000,000 | 2 โ 10 person-years | Enterprise system |
| Very Large | 1M โ 10M | 10 โ 100 person-years | OS, browser, ERP |
| Massive | > 10M | 100+ person-years | OS kernel, cloud platform |
| Language | Avg SLOC/dev/month | Your Rate | Comparison |
|---|---|---|---|
| Python | 450.00 | 1,094.00 | +644.00 |
| JavaScript / TypeScript | 400.00 | 1,094.00 | +694.00 |
| Java | 275.00 | 1,094.00 | +819.00 |
| C# | 300.00 | 1,094.00 | +794.00 |
| C / C++ | 200.00 | 1,094.00 | +894.00 |
| Go | 350.00 | 1,094.00 | +744.00 |
| Rust | 250.00 | 1,094.00 | +844.00 |
Lines of Code (LOC) is one of the simplest and most widely used software metrics. While it doesn't directly measure code quality or productivity, it provides useful context about codebase size, composition, and documentation levels.
This calculator breaks down your code into four categories: Source Lines of Code (SLOC, executable statements), comment lines, blank lines, and total lines. It also computes the comment ratio, which indicates documentation density. A well-documented codebase typically has 15โ30% comment ratio.
While LOC has well-known limitations as a productivity metric, it remains valuable for effort estimation, comparing code composition across modules, and tracking codebase growth over time. Combined with other metrics like complexity and coverage, it provides a complete picture of codebase health.
Use this calculator to quickly assess codebase composition and documentation levels. The comment ratio helps identify under-documented modules, and tracking LOC growth over time reveals development velocity trends.
SLOC = Total Lines โ Blank Lines โ Comment Lines
Comment Ratio = (Comment Lines / Total Lines) ร 100
Blank Ratio = (Blank Lines / Total Lines) ร 100
Code Ratio = (SLOC / Total Lines) ร 100Result: 35,000 SLOC, 14% comment ratio
SLOC = 50,000 โ 8,000 โ 7,000 = 35,000 source lines. Comment ratio is 7,000/50,000 = 14%. Blank ratio is 16%. This indicates moderate documentation levels โ consider improving doc coverage in complex modules.
While raw LOC is easy to measure, the real value comes from analyzing composition and trends. A codebase with 30% comments and 70% executable code is likely well-documented. One with 2% comments and 18% blank lines might need documentation work.
Industry data suggests experienced developers produce 10โ50 net SLOC per day for production-quality code (including tests, reviews, and debugging). This varies dramatically by language, complexity, and team maturity. Use your team's historical rate for custom estimates.
Plotting SLOC over time reveals development patterns. Healthy projects show steady growth with occasional decreases during refactoring phases. Explosive growth without corresponding test growth is a warning sign for quality issues.
Last updated:
No. LOC measures output volume, not value delivered. A developer who deletes 500 lines of redundant code creates more value than one who adds 500 lines. Use LOC for sizing and estimation, not individual performance.
LOC counts every line including blanks and comments. SLOC (Source Lines of Code) counts only executable code lines, excluding blanks and comments. SLOC provides a more consistent measure of actual code volume.
Between 15โ30% indicates healthy documentation. Below 10% suggests under-documented code. Above 40% may indicate over-commenting or commented-out code that should be deleted. Quality of comments matters more than quantity.
Empirical studies show moderate correlation between SLOC and development effort. The COCOMO model uses SLOC as a primary input. However, complexity, domain knowledge, and team experience have stronger effects on actual effort.
Exclude generated code from LOC metrics. Auto-generated files inflate size metrics without reflecting human effort. Most counting tools support exclusion patterns for generated code directories.
Higher-level languages express the same functionality in fewer lines. A Python implementation typically uses 3โ5ร fewer lines than C for equivalent logic. Compare LOC within the same language, not across languages.
Calculate McCabe cyclomatic complexity from edges, nodes, and connected components. Classify code complexity and risk levels.
Estimate technical debt in hours and as a ratio of development effort. Prioritize remediation based on complexity and impact.
Estimate Git repository size from objects, LFS files, and history depth. Calculate expected clone times at different speeds.