{"id":13841694,"url":"https://github.com/xcatliu/cqc","last_synced_at":"2025-04-06T04:09:34.151Z","repository":{"id":57210287,"uuid":"104019661","full_name":"xcatliu/cqc","owner":"xcatliu","description":"Code Quality Checker - Check your code quality by running one command.","archived":false,"fork":false,"pushed_at":"2019-05-06T13:37:21.000Z","size":94,"stargazers_count":323,"open_issues_count":7,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T03:09:39.209Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xcatliu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-19T03:05:48.000Z","updated_at":"2024-11-10T07:27:58.000Z","dependencies_parsed_at":"2022-09-01T08:10:30.242Z","dependency_job_id":null,"html_url":"https://github.com/xcatliu/cqc","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcatliu%2Fcqc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcatliu%2Fcqc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcatliu%2Fcqc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcatliu%2Fcqc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xcatliu","download_url":"https://codeload.github.com/xcatliu/cqc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430869,"owners_count":20937874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T17:01:18.620Z","updated_at":"2025-04-06T04:09:34.033Z","avatar_url":"https://github.com/xcatliu.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","JavaScript (485)"],"sub_categories":[],"readme":"# Code Quality Checker\n\n[![Build Status](https://img.shields.io/travis/xcatliu/cqc.svg)](https://travis-ci.org/xcatliu/cqc) [![npm package](https://img.shields.io/npm/v/cqc.svg)](https://www.npmjs.org/package/cqc) [![npm downloads](http://img.shields.io/npm/dm/cqc.svg)](https://www.npmjs.org/package/cqc) [![Coveralls](https://img.shields.io/coveralls/xcatliu/cqc.svg)](https://coveralls.io/github/xcatliu/cqc)\n\nCheck your code quality by running one command.\n\n## Supported Languages\n\n- js, jsx, vue\n- css, less, scss, sass, styl\n\n## Quick Start\n\nInstall cqc:\n\n```bash\nnpm install -g cqc\n```\n\nRun Code Quality Checker for all JavaScript files in `src` directory:\n\n```bash\ncqc src\n```\n\nOutput:\n\n```\nNumber of files:        12\nSource lines of code:   696\nDuplicate rate:         3.23%\nHigh complexity rate:   0.00%\n```\n\n## Usage\n\nTo run cqc, use the following format:\n\n```bash\ncqc [options] \u003cfile|dir|glob\u003e*\n```\n\nFor example:\n\n```bash\ncqc src/file1.js src/file2.js\n```\n\nor\n\n```bash\ncqc src lib\n```\n\nor\n\n```bash\ncqc src/**/*.js src/**/*.jsx\n```\n\nPlease note that when passing a glob as a parameter, it will be expanded by your shell. The results of the expansion can vary depending on your shell, and its configuration. If you want to use node `glob` syntax, you have to quote your parameter (using double quotes if you need it to run in Windows), as follows:\n\n```bash\ncqc \"src/**/*.js\" \"src/**/*.jsx\"\n```\n\n### Options\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\nFiles options |\n`--ext` | string | `.js` | Specify file extensions. `--ext` is only used when the arguments are directories. If you use glob patterns or file names, then `--ext` is ignored.\n`--ignore-path` | path | | Specify path of ignore file\n`--ignore-pattern` | pattern | | Pattern of files to ignore\n`--filter-pattern` | pattern | | Output percentage of all files but only details that related to the filter pattern\nScript options |\n`--jscpd-min-lines` | number | `5` | Set the min size of duplication in code lines\n`--jscpd-min-tokens` | number | `70` | Set the min size of duplication in code tokens\n`--complexity-max` | number | `10` | Set the allowed max complexity of a function\nDisable options |\n`--disable-base` | | | Disable base checker\n`--disable-sloc` | | | Disable sloc checker\n`--disable-jscpd` | | | Disable jscpd checker\n`--disable-complexity` | | | Disable complexity checker\nReporter options |\n`-f`, `--format` | string | | Specify an output format. Supported format: json\n`--verbose` | | | Verbose mode. A lot more information output\n`--threshold-jscpd` | number | | Set the jscpd threshold, process will exit if duplicate rate is more than threshold\n`--threshold-complexity` | number | | Set the complexity threshold, process will exit if complexity rate is more than threshold\n\nExamples:\n\n#### Set the file extensions\n\n```bash\ncqc src --ext \".js,.jsx\"\n```\n\n#### Set the ignore file path\n\n```bash\ncqc src/**/*.js --ignore-path \".gitignore,.eslintignore\"\n```\n\n#### Ignore vendors and third-party libraries\n\n```bash\ncqc src/**/*.js --ignore-pattern \"src/vendor/**/*.js,src/third-party/**/*.js\"\n```\n\n#### Output json format\n\n```bash\ncqc src/**/*.js --format json\n```\n\nOutput:\n\n```json\n{\n    \"base\": {\n        \"numberOfFiles\": 12\n    },\n    \"sloc\": {\n        \"source\": 696\n    },\n    \"jscpd\": {\n        \"percentage\": \"3.23\"\n    },\n    \"complexity\": {\n        \"percentage\": \"0.00\"\n    }\n}\n```\n\n#### Verbose mode\n\n```bash\ncqc src/**/*.js --verbose\n```\n\nOutput:\n\n```\nNumber of files: 12\nFile list:\n    - E:\\github\\xcatliu\\cqc\\src\\BaseChecker\\index.js\n    - E:\\github\\xcatliu\\cqc\\src\\CheckerResult\\cqcReporter.js\n    - E:\\github\\xcatliu\\cqc\\src\\CheckerResult\\index.js\n    - E:\\github\\xcatliu\\cqc\\src\\CheckerResult\\logStdout.js\n    - E:\\github\\xcatliu\\cqc\\src\\CodeQualityChecker\\index.js\n    - E:\\github\\xcatliu\\cqc\\src\\ComplexityChecker\\eslintConfig.js\n    - E:\\github\\xcatliu\\cqc\\src\\ComplexityChecker\\getParserFromFilepath.js\n    - E:\\github\\xcatliu\\cqc\\src\\ComplexityChecker\\index.js\n    - E:\\github\\xcatliu\\cqc\\src\\JscpdChecker\\getLanguageFromFilepath.js\n    - E:\\github\\xcatliu\\cqc\\src\\JscpdChecker\\index.js\n    - E:\\github\\xcatliu\\cqc\\src\\JscpdChecker\\jscpdReporter.js\n    - E:\\github\\xcatliu\\cqc\\src\\SlocChecker\\index.js\n\nPhysical lines:             854\nSource lines of code:       696\nComments:                   36\nSingle-line comments:       36\nBlock comments:             0\nMixed source and comments:  0\nEmpty lines:                122\nTODO's:                     1\n\nDuplicate rate:             3.23%\nFiles of duplicated code:   3\nCount of duplicated code:   2\nLines of duplicated code:   28\nDuplication details:\n    - E:\\github\\xcatliu\\cqc\\src\\CheckerResult\\logStdout.js: 67-71\n      E:\\github\\xcatliu\\cqc\\src\\CheckerResult\\logStdout.js: 73-77\n    - E:\\github\\xcatliu\\cqc\\src\\JscpdChecker\\index.js: 42-64\n      E:\\github\\xcatliu\\cqc\\src\\JscpdChecker\\jscpdReporter.js: 22-44\n\nHigh complexity rate:                0.00%\nNumber of functions:                 58\nNumber of high complexity functions: 0\n```\n\n#### Set the jscpd threshold\n\n```bash\ncqc src --threshold-jscpd 3\n```\n\nOutput:\n\n```\nNumber of files:        12\nSource lines of code:   696\nDuplicate rate:         3.23%\nHigh complexity rate:   0.00%\n\nOops, duplicate rate is MORE than threshold 3%, please check the details by adding --verbose option.\n```\n\n## API\n\nIt's also able to use cqc as a node module:\n\n```js\nconst CodeQualityChecker = require('cqc');\nconst codeQualityChecker = new CodeQualityChecker();\n\n// This will return a checkerResult object which include the check result\nconst cqcResult = codeQualityChecker.check([\n    'src'\n], {\n    ext: '.js',\n    ignorePath: '.gitignore,.eslintignore',\n    ignorePattern: 'src/vendor/**/*.js,src/third-party/**/*.js',\n    filterPattern: 'src/path/to/filterPattern',\n\n    jscpdMinLines: 5,\n    jspcdMinTokens: 70,\n    complexityMax: 10,\n\n    disableBase: false,\n    disableSloc: false,\n    disableJscpd: false,\n    disableComplexity: false,\n\n    format: undefined,\n    verbose: true,\n    thresholdJscpd: 3,\n    thresholdComplexity: 10\n});\n\n// Calling report function will console.log result like cli did\ncqcResult.report({\n    format: undefined,\n    verbose: true,\n    thresholdJscpd: 3,\n    thresholdComplexity: 10\n});\n```\n\n## Concept Definition\n\nConcept | Definition\n------- | ----------\nNumber of files             | The number of input files\nSource lines of code        | The lines of code except commants and blank lines\nLines of duplicated code    | Lines of code (more than 5 lines or more than 70 tokens) which is exactly the same between two files, or in different place of one file\nDuplicate rate              | Lines of duplicated code / Source lines of code\nComplexity                  | https://en.wikipedia.org/wiki/Cyclomatic_complexity\nNumber of functions         | The number of functions\nNumber of high complexity functions | The number of functions which has complexity more than 10\nHigh complexity rate        | Number of high complexity functions / Number of functions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcatliu%2Fcqc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcatliu%2Fcqc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcatliu%2Fcqc/lists"}