Code Quality Report (Complexity & Duplicate Code)
Lines of code, complexity, duplicates and hotspots for a whole project, on your device.
Try before you buy.
- Free preview: the language and line totals of your code, with the first rows (up to 10) of the hotspot table.
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment that never renews. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment that never renews.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
Your project
All of the folder is read in your browser. What Git ignores (.gitignore) and dependency and build folders are left out.
Paste code instead
Paste more files one by one under other names; each is measured with the others.
Thresholds and options
Choose a project folder, files or a ZIP — or open the example project.
The report
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the Code Quality Report (Complexity & Duplicate Code)
Choose a project folder, drop a ZIP or source files, or paste code, and get a report on the code in seconds: how many lines of code, comment and blank lines it has in each language and folder, how complex each function is, where code is copied from one place to another, and which files are the hotspots to look at first. Everything is read and measured in a background worker in your browser; nothing is uploaded.
Lines are counted the way cloc counts them. For JavaScript, TypeScript, Python, Java, C#, Go, PHP, Ruby, C, C++ and Rust every function and method is measured: cyclomatic complexity (counted as lizard counts it), Cognitive Complexity (as G. Ann Campbell’s white paper defines it: breaks in the flow, plus nesting), code lines, parameters and the deepest nesting. Copied blocks of 50 tokens or more are found across all files, as jscpd finds them, and each file gets a maintainability index from 0 to 100. Files that Git ignores (.gitignore at every level), dependency and build folders, lock files, minified files and generated code are left out, and listed.
Without a pass the report is a free preview: the summary counts and the totals by language in full, and the first rows of the hotspot table. With a Pro pass every function, every duplicate block, the folders and the files show, and the HTML and PDF report, the CSV tables, the Code Quality JSON for merge requests and the Markdown summary unlock.
How to use it
- Press Choose a project folder (or drag the folder onto the box), drop a ZIP of the project or some source files, or open Paste code instead. The Example project shows a report on a small shop back end.
- Wait a moment while the files are read and measured; the status line counts them. Files left out — ignored, vendored, generated, binary or too large — are listed under Left out.
- Read the summary, the lines by language and the Hotspots: files ranked by their findings, such as a function with a Cognitive Complexity over 15 or a block copied from another file.
- With a pass, sort and filter the Functions table, check the duplicate blocks and the folders, and download the HTML or PDF report, the CSV tables or the Code Quality JSON; the free preview shows the totals and the first hotspots.
- Change the limits under Thresholds and options to match your team’s rules; the report is made again at once.
Examples
cartTotal(lines, coupon, member): a for loop with an if inside it, food discounts in an if inside that, an else if with &&, a coupon if with && and an else if holding a ternary
Cognitive Complexity 19 (over 15: a major finding), cyclomatic complexity 13 (over 10: a minor finding), 3 parameters, nested 3 deep.
From the example project. The paper’s own examples score as it says: sumOfPrimes 7, getWords 1, and its longest method 35.
src/cart.ts and src/invoice.ts both build their printed lines with the same loop
One duplicate block of 7 lines in each file; each copy is a minor finding, so src/cart.ts tops the hotspots with a score of 5 (3 for the major finding, 1 for each minor one).
dist/app.min.js, package-lock.json and .gitignore in the example project
Two vendored files (a build folder and a tool file) and one generated file (a lock file) are listed under Left out and not counted.
Common uses
- Getting to know a codebase you inherit: its languages, its size and its most complex functions.
- Checking a pull request’s files before review, or finding the functions to refactor first.
- Adding a code quality report to a merge request from a CI job’s files, without a server-side scanner.
- Tracking lines of code, duplication and complexity of a project over time with the CSV tables.
How the measures are counted
- Lines: a line with only white space is blank (inside a comment too), a line with any code is code — a trailing comment does not change that — and the rest are comment lines. Strings are code, so
"http://example.com"is not a comment. Python docstrings count as comments, as in cloc. - Cyclomatic complexity: 1 for the function, plus 1 for each
if,for,while,case,catch,&&,||and ternary?, with each language’s own words (elif,except,and,orin Python;elsif,unless,until,when,rescuein Ruby; each match arm and the?operator in Rust). - Cognitive Complexity: +1 for each
if,else if,else, ternary,switch, loop andcatch, for each sequence of like boolean operators, for a jump to a label and for recursion, and +1 more for each level of nesting anif, ternary,switch, loop orcatchsits at. Lambdas and nested functions add a level of nesting and count in the function that holds them;try,finallyand null-coalescing operators add nothing. - Nesting: the deepest nest of
if, loop,switchandtryblocks in a function. Maintainability index: max(0, (171 − 5.2 ln V − 0.23 G − 16.2 ln L) × 100 / 171), with V the Halstead volume, G the cyclomatic complexity and L the lines of code of the file; 20 and over is good, 10–19 moderate, under 10 low.
What is left out
- Files Git ignores: every
.gitignorein the project, at every level, as Git reads them. - Vendored paths: dependency folders (
node_modules,vendor,bower_components), build output (dist,cache), third-party libraries (jQuery, Bootstrap …), tool folders and wrappers (.vscode,.github,gradlew), and declaration files (.d.ts). - Generated files: lock files (
package-lock.json,yarn.lock,Cargo.lock,poetry.lock…), minified JavaScript and CSS (lines over 110 characters on average), source maps, and files that say they are generated (Code generated … DO NOT EDIT, protocol buffers, designer files). - Binary files, files over 2 MB, and files that are not code (images, documents).
- Untick Leave out vendored and generated files or Follow .gitignore files to count them anyway.
The exports
- HTML report: one file with every table, readable in light and dark, to share or keep with a release.
- PDF: the summary, the hotspots, the most complex functions and the largest duplicates, on A4 landscape pages.
- CSV tables: files, functions, duplicates and languages, one row each, for a spreadsheet.
- Code Quality JSON (GitLab): the findings in the Code Climate format a merge request’s code quality widget reads: a JSON array of issues with a description, check name, severity, a stable fingerprint and the relative path and line, without a byte-order mark. Save it as
gl-code-quality-report.jsonin a CI job and declare it as the job’s code quality report. - Copy summary: the totals and the top hotspots as Markdown, to paste into a pull request or a ticket.
Limitations
- Functions are found from the code’s tokens, not compiled: unusual macros, code generated at run time and very unusual syntax can be measured a little differently from a compiler-based tool.
- Up to 50,000 files and 300 MB of code; a file over 2 MB is left out. Duplicates are searched in the first 3 million tokens of a very large project.
- Recursion counts when a function calls itself directly; calls through other functions are not followed.
- A ZIP must use the usual compression (deflate); a dropped folder skips .git and node_modules without reading them.
Privacy
On this device: nothing is sent
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
What do I get without a pass?
Without a pass, Code Quality Report (Complexity & Duplicate Code) shows the language and line totals of your code, with the first rows (up to 10) of the hotspot table. Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.
Is my code uploaded?
No. The files are read in a worker in your browser and the report is made there; nothing is sent anywhere.
Why do cyclomatic complexity and Cognitive Complexity differ?
Cyclomatic complexity counts the paths through a function, so a switch with ten cases scores 11 and a deeply nested loop the same as a flat one. Cognitive Complexity scores how hard the code is to follow: the switch scores 1, and each level of nesting adds to what is inside it. A function can be easy to test but hard to read, or the other way round.
What does the free preview show?
Every file is read and measured. The preview shows the summary counts, the lines by language, and the first rows of the hotspot table (half of it, up to 10 rows). The functions, the duplicate blocks, the folders and the files tables, and every export, come with a pass.
Can I use it in continuous integration?
The report runs in your browser, not in a CI runner. To show its findings in a merge request, download the Code Quality JSON (with a pass) and publish it from a CI job as the job’s code quality report; the CSV tables track the numbers between releases.
Which thresholds should I use?
The defaults are common ones: Cognitive Complexity 15 per function, cyclomatic complexity 10, 60 code lines, 7 parameters, nesting 4 deep, 1,000 code lines per file and duplicates from 50 tokens. Set your team’s own under Thresholds and options; they are kept in this browser.