This is a very simple implementation of Javascript code quality analysis. Code critic uses various open source libraries to find vulnerabilities in code and reports then to the user.
- NodeJS 10.0+
- Ruby 2.0+
- NPM 1.4+
Run the following:
bundle install
npm install
npm test
npm start
The application will be available at http://localhost:3000/
- JSHint: JSHint reviews the code for styling and common problems.
- ScanJS: A Security scanner that reviews the code for major vulnerabilities.
- David: Checks each dependency in package.json and validates whether there is a newer version available.
- Complexity-Report: Generates a complex mathematical analysis of the source code trying to identify the maintainability effort.
- Flay-JS: Reviews the code for structural similarities and copy pasted snippets and helps keep the code DRY.
In addition to code quality analysis, there are various open source libraries that are used here for software development. Please refer to the same in package.json
.
Finally, we use SyntaxHighlighter to display source code on the UI.
CodeCritic provides a very opinionated point of view of writing JavaScript code.
Any feedback generated by running one of the above code quality checks is assumed to be an issue.
Code Critic uses a simple algorithm for rating files and generating a roll up score for each code base.
Total # of Issues in the file | Rating |
---|
10 | 1 5 && <= 10 | 2 2 && <= 5 | 3 0 && <= 2 | 4 0 | 5
Once all files have been rated, all ratings are added and divided by the total number of files to get a total score.
The application uses preconfigured rules for JSHint and Complexity analysis and the same can be found under ./config/
. Please note that these rules are only indicative and you should feel free to change any if you do not agree with them.
The ./config/
directory has 2 types of files:
- config files for thresholds.
- ignore files for the file patterns that should be excluded from analysis.
Please read the guidelines.
The tool is available under MIT License. Please review the LICENSE
file under the repository.