Files
MoGoEagleEye/codequality/custom-pmd-ruleset.xml
2023-09-20 19:38:59 +08:00

62 lines
3.3 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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>.*/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>-->
<!-- 应避免重新分配catch语句中捕获的异常变量 -->
<rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables" />
<!-- 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/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>