All Projects → vigneshshanmugam → Js Cpa

vigneshshanmugam / Js Cpa

Licence: mit
Code pattern analysis for JS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Js Cpa

Ruby warning filter
Verbose Ruby mode without the noise
Stars: ✭ 9 (-92.5%)
Mutual labels:  code-quality
Prettier action
GitHub action for running prettier on your projects pull requests
Stars: ✭ 77 (-35.83%)
Mutual labels:  code-quality
Wemake Python Styleguide
The strictest and most opinionated python linter ever!
Stars: ✭ 1,714 (+1328.33%)
Mutual labels:  code-quality
Unused
Deprecated; see https://github.com/unused-code/unused
Stars: ✭ 879 (+632.5%)
Mutual labels:  code-quality
Static Analysis
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
Stars: ✭ 9,310 (+7658.33%)
Mutual labels:  code-quality
Typo3scan
Scans TYPO3 extensions for usage of deprecated and or changed code
Stars: ✭ 83 (-30.83%)
Mutual labels:  code-quality
Checkstyle Action
Run Java checkstyle with reviewdog in github actions
Stars: ✭ 26 (-78.33%)
Mutual labels:  code-quality
Coveralls Ruby
Coveralls for Ruby
Stars: ✭ 115 (-4.17%)
Mutual labels:  code-quality
Cross Platform Node Guide
📗 How to write cross-platform Node.js code
Stars: ✭ 1,161 (+867.5%)
Mutual labels:  code-quality
Platform
Code Climate Engineering Data Platform
Stars: ✭ 104 (-13.33%)
Mutual labels:  code-quality
Typewiz
Automatically discover and add missing types in your TypeScript code
Stars: ✭ 1,026 (+755%)
Mutual labels:  code-quality
Eslint Config Ivweb
ESLint shareable config for the IVWEB JavaScript style guide.
Stars: ✭ 59 (-50.83%)
Mutual labels:  code-quality
Test Each
🤖 Repeat tests. Repeat tests. Repeat tests.
Stars: ✭ 89 (-25.83%)
Mutual labels:  code-quality
Phpqa
Docker image that provides static analysis tools for PHP
Stars: ✭ 853 (+610.83%)
Mutual labels:  code-quality
Pkgnet
R package for analyzing other R packages via graph representations of their dependencies
Stars: ✭ 107 (-10.83%)
Mutual labels:  code-quality
Feflow
🚀 A command line tool aims to improve front-end engineer workflow and standard, powered by TypeScript.
Stars: ✭ 942 (+685%)
Mutual labels:  code-quality
Hippo
PHP standards checker.
Stars: ✭ 82 (-31.67%)
Mutual labels:  code-quality
Editorconfig Checker
A tool to verify that your files are in harmony with your .editorconfig
Stars: ✭ 119 (-0.83%)
Mutual labels:  code-quality
Goreadme
Generate readme file from Go doc. Now available with Github actions!
Stars: ✭ 113 (-5.83%)
Mutual labels:  code-quality
Pscodehealth
PowerShell module gathering PowerShell code quality and maintainability metrics
Stars: ✭ 104 (-13.33%)
Mutual labels:  code-quality

js-cpa

Identify structurally similar functions that are duplicated across a JavaScript bundle/file seamlessly.

Running it on Inferno

CPA on Inferno

Features

  • Works only across function boundaries
  • Matches the longest common subsequence and ignores the children
  • Ignores comments on the output
  • HTML report generation

Related

Installation

npm install -g js-cpa

CLI

Usage: js-cpa [options] <file ...>


Options:

  -V, --version              output the version number
  -f, --filelist             read filelist from STDIN stream - if/when you cross ARG_MAX. eg: ls *.js | js-cpa -f
  -m, --module               parse files with sourceType=module
  -l, --language <language>  language (js|ts|flow)
  -t, --threshold <n>        threshold (in bytes)
  -C, --no-colors            disable colors in output
  -R, --report <type>        generate reports (html|term)
  -o, --report-file <path>   path for report generation
  -h, --help                 output usage information

API

const { findDuplicates, stringify }= require('js-cpa');
const fs = require("fs");
const code = fs.readFileSync(filePath, "utf-8");
const duplicates = findDuplicates(code, {
  filename: "test"
});

process.stdout.write(stringify(duplicates)); // prints to stdout
Options

  • filename - name of the file used in the output
  • sourceType - denotes the mode the code should be parsed in. eg - script|module
  • language - denotes the language. eg - (js|ts|flow)
  • threshold - threshold in bytes
findDuplicates(code, opts)

Finds the optimal duplicate functions that are structurally similar. It tries to find the longest matching subexpression across the AST which ignores the children(inner function) if the parent(outer function) is already mached

findAllDuplicates(code, opts)

Finds all duplicate functions that are structurally similar.

stringify(duplicates, options)

Gets the output in a more presentable way

Options

  • colors - enable colors on the stdout
  • newline - prints newline after each duplicates
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].