欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

重复代码检查工具Simian

程序员文章站 2022-07-13 21:46:01
...

简介
Simian是一个可跨平台使用的重复代码检测工具,能够检测代码片段中除了空格、注释及换行外的内容是否完全一致,且支持的语言十分广泛

官网

Simian官网:http://www.harukizaemon.com/simian/index.html

下载

http://www.harukizaemon.com/simian/get_it_now.html地址下载

重复代码检查工具Simian

将这2个文件都下载下来,使用MD5文件校验上面的文件是否下载完毕了。

重复代码检查工具Simian

重复代码检查工具Simian

证明文件下载的文件是完整的。

然后解压simian-2.5.10.tar.gz,并把解压后的文件放到D:\Program_Files\simian-2.5.10目录下

重复代码检查工具Simian

使用

使用bin目录下的jar

重复代码检查工具Simian

执行命令,从src目录下找到重复3行的重复代码,并将找到的结果放入D:\result.txt中

java -jar D:\Program_Files\simian-2.5.10\bin\simian-2.5.10.jar -threshold=3 "D:\workspace\idea\father\src\**\*.java" >> D:\result.txt

重复代码检查工具Simian

重复代码检查工具Simian

Simian命令行的格式

java -jar simian.jar [options] [files]

Usage: [options] [files]

命令 描述
-balanceCurlyBraces[+/-] Accounts for curly braces when breaking lines
-balanceParentheses[+/-] Accounts for parentheses when breaking lines
-balanceSquareBrackets[+/-] Accounts for square brackets when breaking lines
-config=FNAME Reads the configuration from the specifiedfile
-defaultLanguage=LANG Assumes files are in the specified language if none can be inferred
-excludes=SPEC Excludes files matching the specified pattern
-failOnDuplication[+/-/%] Exits with a failure return code if duplication detected
-formatter=TYPE[:FNAME] Uses the specified output format when reporting
-ignoreBlocks=START:END Ignores all lines between START/END
-ignoreCharacterCase[+/-] Matches character literals irrespective of case
-ignoreCharacters[+/-] Completely ignores character literals
-ignoreCurlyBraces[+/-] Completely ignores curly braces
-ignoreIdentifierCase[+/-] Matches identifiers irresepctive of case
-ignoreIdentifiers[+/-] Completely ignores identifiers
-ignoreLiterals[+/-] Completely ignores all literals (strings, numbers and characters)
-ignoreModifiers[+/-] Ignores modifiers (public, private, static, etc.)
-ignoreNumbers[+/-] Completely ignores numbers
-ignoreOverlappingBlocks[+/-] Ignores blocks that wholly or partially overlap
-ignoreRegions[+/-] Ignores all lines between #region/#endregion
-ignoreStringCase[+/-] Matches string literals irrespective of case
-ignoreStrings[+/-] Completely ignores the contents of strings
-ignoreSubtypeNames[+/-] Matches on similar type names (eg. Reader and FilterReader)
-ignoreVariableNames[+/-] Completely ignores variable names (fields, parameters and locals)
-includes=SPEC Including files matching the specified pattern
-language=LANG Assumes ALL files are in the specified language
-reportDuplicateText[+/-] Prints the duplicate text in reports
-threshold=COUNT Matches will contain at least the specified number of lines