mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-28 05:43:50 +00:00
2296c624fa
Summary: Integrate pmd on the Java API to catch and report common Java coding problems; fix or suppress a basic set of PMD checks. Link pmd into java build / CI Add a pmd dependency to maven Add a jpmd target to Makefile which runs pmd Add a workflow to Circle CI which runs pmd Configure an initial default pmd for CI Repair lots of very simple PMD reports generated when we apply pmd-rules.xml Repair or exception for PMD rules in the CloseResource category, which finds unclosed AutoCloseable resources. We special-case the configuration of CloseResource and use the // NOPMD comment in source the avoid reports where we are the API creating an AutoCloseable, and therefore returning an unclosed resource is correct behaviour. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11221 Reviewed By: akankshamahajan15 Differential Revision: D50369930 Pulled By: jowlyzhang fbshipit-source-id: a41c36b44b3bab7644df3e9cc16afbdf33b84f6b
62 lines
2.9 KiB
XML
62 lines
2.9 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<ruleset name="Custom Rules"
|
|
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
|
|
|
<description>
|
|
Custom rules for checking RocksDB
|
|
</description>
|
|
|
|
|
|
<!-- Use PMD rules from a few sets, and then make exceptions -->
|
|
<rule ref="category/java/codestyle.xml">
|
|
<!-- These problems are acceptable in perpertuity -->
|
|
<exclude name="AvoidUsingNativeCode"/>
|
|
<exclude name="LongVariable"/>
|
|
<exclude name="ShortVariable"/>
|
|
<exclude name="ShortClassName"/>
|
|
<exclude name="OnlyOneReturn"/>
|
|
<exclude name="FieldNamingConventions"/>
|
|
<exclude name="FormalParameterNamingConventions"/>
|
|
<exclude name="LinguisticNaming"/>
|
|
<!-- These could be fixed if we take the time to do it -->
|
|
<exclude name="CommentDefaultAccessModifier"/>
|
|
<exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
|
|
<exclude name="FinalParameterInAbstractMethod"/>
|
|
<exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
|
|
<exclude name="MethodArgumentCouldBeFinal"/>
|
|
<exclude name="LocalVariableNamingConventions"/>
|
|
<exclude name="LocalVariableCouldBeFinal"/>
|
|
<exclude name="ControlStatementBraces"/>
|
|
<exclude name="CallSuperInConstructor"/>
|
|
<exclude name="ControlStatementBraces"/>
|
|
<exclude name="MethodNamingConventions"/>
|
|
<exclude name="UselessParentheses"/>
|
|
<exclude name="AtLeastOneConstructor"/>
|
|
</rule>
|
|
<rule ref="category/java/errorprone.xml">
|
|
<exclude name="AvoidFieldNameMatchingMethodName"/>
|
|
</rule>
|
|
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
|
|
<properties>
|
|
<property name="ignoreMagicNumbers" value="-1,0,1,2,0x0,0x1,0xff" />
|
|
<property name="ignoreExpressions" value="true,false" />
|
|
</properties>
|
|
</rule>
|
|
<rule ref="category/java/bestpractices.xml">
|
|
<exclude name="UseVarargs"/>
|
|
</rule>
|
|
|
|
<rule ref="category/java/errorprone.xml/CloseResource">
|
|
<properties>
|
|
<property name="types" value="java.lang.AutoCloseable,java.sql.Connection,java.sql.Statement,java.sql.ResultSet" />
|
|
<property name="closeAsDefaultTarget" value="true" />
|
|
<!-- we allow these org.rocksdb types as generally our API is opening them for the user. -->
|
|
<property name="allowedResourceTypes" value="java.io.ByteArrayOutputStream|java.io.ByteArrayInputStream|java.io.StringWriter|java.io.CharArrayWriter|java.util.stream.Stream|java.util.stream.IntStream|java.util.stream.LongStream|java.util.stream.DoubleStream" />
|
|
<property name="closeNotInFinally" value="false" />
|
|
</properties>
|
|
</rule>
|
|
|
|
</ruleset> |