代碼重複率檢查工具jsinspect

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

安裝:

npm install -g jsinspect

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

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

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

意思是檢查 ./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文件位於項目目錄中,則將使用其值代替上面列出的默認值。例如:

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

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

jsinspect -t 50 --ignore "test" ./path/to/src

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章