代碼重複率檢查工具jsinspect

檢查重複代碼,去掉冗餘代碼。node

安裝:正則表達式

npm install -g jsinspect

用法:jsinspect [options] <paths ...>npm

檢測複製粘貼和結構相似的JavaScript代碼json

示例:jsinspect -I -L -t 20 --ignore "test" ./path/to/src ide

意思是檢查 ./path/to/src 路徑下文件 -I不匹配標識符 -L不匹配文字 -t 20匹配大於20個字節的代碼 忽略test文件工具

Options:

  -h, --help                         output usage information 輸出使用信息
  -V, --version                      output the version number 輸出版本號
  -t, --threshold <number>           number of nodes (default: 30) 檢查字節閥值(默認是30個字節)
  -m, --min-instances <number>       min instances for a match (default: 2) 匹配的最小實例(默認2個字節)
  -c, --config [config]              path to config file (default: .jsinspectrc) 配置文件路徑
  -r, --reporter [default|json|pmd]  specify the reporter to use 指定類型使用
  -I, --no-identifiers               do not match identifiers 不匹配標識符
  -L, --no-literals                  do not match literals 不匹配文字
  -C, --no-color                     disable colors 禁用顏色
  --ignore <pattern>                 ignore paths matching a regex 忽略與正則表達式匹配的路徑
  --truncate <number>                length to truncate lines (default: 100, off: 0) 截線長度
  --debug                            print debug information 打印調試信息

若是.jsinspectrc文件位於項目目錄中,則將使用其值代替上面列出的默認值。例如:spa

{
  "threshold":     30,
  "identifiers":   true,
  "literals":      true,
  "color":         true,
  "minInstances":  2,
  "ignore":        "test|spec|mock",
  "reporter":      "json",
  "truncate":      100,
}

首次使用項目時,您可能但願使用如下選項運行該工具,同時在lib/src目錄上顯式運行,而不是test/spec目錄。debug

jsinspect -t 50 --ignore "test" ./path/to/src
相關文章
相關標籤/搜索