73 lines
3.8 KiB
XML
73 lines
3.8 KiB
XML
<?xml version="1.0"?>
|
||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Custom ruleset"
|
||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
|
||
<description>
|
||
This ruleset checks my code for bad stuff
|
||
</description>
|
||
|
||
<!--https://pmd.github.io/pmd-5.6.1/pmd-java/index.html-->
|
||
|
||
<exclude-pattern>.*.kt</exclude-pattern>
|
||
<exclude-pattern>.*/R.java</exclude-pattern>
|
||
<exclude-pattern>.*/gen/.*</exclude-pattern>
|
||
<exclude-pattern>.*Dagger*.*</exclude-pattern>
|
||
|
||
<!-- 最佳实践 -->
|
||
|
||
<!-- 用log代替e.PrintStackTrace -->
|
||
<!-- <rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace" />-->
|
||
<!-- for/foreach 避免index重新赋值 -->
|
||
<!-- <rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables">-->
|
||
<!-- <properties>-->
|
||
<!-- <property name="foreachReassign" value="deny" />-->
|
||
<!-- <property name="forReassign" value="deny" />-->
|
||
<!-- </properties>-->
|
||
<!-- </rule>-->
|
||
|
||
<!-- StringBuffers/StringBuilders可能会大幅增长,因此如果保存在寿命较长的对象中,可能会成为内存泄漏的来源 -->
|
||
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField" />
|
||
<!-- 在同一行中声明多个变量,会比较混乱 -->
|
||
<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine">
|
||
<properties>
|
||
<property name="strictMode" value="true" />
|
||
</properties>
|
||
</rule>
|
||
<!-- 检查赋值字段未使用问题 -->
|
||
<rule ref="category/java/bestpractices.xml/UnusedAssignment">
|
||
<properties>
|
||
<property name="checkUnusedPrefixIncrement" value="true" />
|
||
<property name="reportUnusedVariables" value="true" />
|
||
</properties>
|
||
</rule>
|
||
<!-- 检查未使用的局部变量 -->
|
||
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />
|
||
<!-- <rule ref="category/java/bestpractices.xml/UseStandardCharsets" />-->
|
||
|
||
<!-- 容易出现运行时错误 -->
|
||
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" />
|
||
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" />
|
||
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" />
|
||
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" />
|
||
<rule ref="category/java/errorprone.xml/BrokenNullCheck" />
|
||
<rule ref="category/java/errorprone.xml/CheckSkipResult" />
|
||
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
|
||
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
|
||
<rule ref="category/java/errorprone.xml/JumbledIncrementer" />
|
||
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" />
|
||
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" />
|
||
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" />
|
||
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement" />
|
||
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" />
|
||
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" />
|
||
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" />
|
||
<!-- 多线程时问题-->
|
||
<rule ref="category/java/multithreading.xml/AvoidThreadGroup" />
|
||
<rule ref="category/java/multithreading.xml/DontCallThreadRun" />
|
||
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
|
||
<!-- 需要优化代码的地方-->
|
||
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
|
||
<!-- 安全问题-->
|
||
<rule ref="category/java/security.xml" />
|
||
</ruleset> |