Count lines and find the longest and most tangled functions in ten languages. Strings and comments are blanked first, so documentation is not complexity.
Waiting for some code
Paste a file. Ten languages are supported, and the language is detected.
Strings and comments are blanked out before anything is counted. Without that, a regex for if matches the word inside a string and inside a comment — and a well-documented file would measure as more complex than the code it documents.
Paste a file to find its longest and most tangled functions.
Every complexity figure here is a keyword count plus one, not a control-flow graph — which is why they are labelled approximate throughout. Use them to notice which function in a file is the worst, and to notice when that gets worse over time. Do not compare them with a number from a real analyser, and do not put them in a gate.
Code Metrics Analyzer runs entirely on your device — your code is read as text in your browser, is never executed, and is never uploaded.
You’re on the Free plan. Compare plans
Every number here is an approximation, and the word is in the field name. Real cyclomatic complexity is computed from a control-flow graph; this counts decision keywords and operators and adds one, which is the shape of the same idea arrived at by counting. On ordinary code the two usually agree closely, and on anything unusual they will not — so nothing here should be compared with a figure from a real analyser or put in a gate.
Strings and comments are blanked before anything is counted, which is what makes the rest worth having. A regex for "if" matches the word inside a string and inside a comment, so a well-documented file would measure as more complex than the code it documents. A brace counter that does not skip strings loses its place on the first brace in a template, and every function boundary after it is wrong.
The line counts are the exact part. Code, comment and blank lines are counted rather than estimated, so the comment ratio is a fact even where the complexity figure is a guess. Each analysis also carries its own caveats, specific to the file rather than generic.
No, and it says so throughout. Real cyclomatic complexity comes from a control-flow graph. This counts decision keywords and operators and adds one — the same idea arrived at by counting. On ordinary code the two agree closely; on unusual code they will not, so do not compare this number with one from a real analyser.
Because otherwise a regex for "if" matches the word inside a string literal and inside a comment, and a well-documented file measures as more complex than the code it documents. A brace counter that does not skip strings also loses its place on the first brace inside a template, which makes every subsequent function boundary wrong.
The line counts — code, comment and blank — and therefore the comment ratio. Those are counted rather than inferred. Everything about functions and complexity is approximate, because finding a function boundary without a parser is a heuristic.
No. Use them to notice which function in a file is the worst, and to notice when that gets worse over time. A gate needs a figure that is stable and defensible, and a keyword count is neither.
The scanner finds function boundaries by keyword and bracket depth, so an unusual style or a construct it does not know produces nothing rather than a wrong answer. The line counts are still exact.
Neither. It is read as text in your browser.
If a tool here saved you some time, you can put something towards the hosting.Buy me a coffee, on Ko-fi, opens in a new tab