| 
10 | 10 | 
 
  | 
11 | 11 | 	<!-- Only rules that don't overlap with CheckStyle! -->  | 
12 | 12 | 
 
  | 
 | 13 | +	<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>  | 
 | 14 | +	<rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/>  | 
13 | 15 | 	<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>  | 
 | 16 | +	<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>  | 
 | 17 | +	<rule ref="category/java/bestpractices.xml/ExhaustiveSwitchHasDefault"/>  | 
 | 18 | +	<rule ref="category/java/bestpractices.xml/LiteralsFirstInComparisons"/>  | 
 | 19 | +	<!-- CheckStyle can't handle this switch behavior -> delegated to PMD -->  | 
 | 20 | +	<rule ref="category/java/bestpractices.xml/NonExhaustiveSwitch"/>  | 
 | 21 | +	<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine">  | 
 | 22 | +		<properties>  | 
 | 23 | +			<property name="strictMode" value="true"/>  | 
 | 24 | +		</properties>  | 
 | 25 | +	</rule>  | 
14 | 26 | 	<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>  | 
 | 27 | +	<rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion"/>  | 
 | 28 | +	<rule ref="category/java/bestpractices.xml/SystemPrintln"/>  | 
 | 29 | +	<rule ref="category/java/bestpractices.xml/UnusedAssignment"/>  | 
 | 30 | +	<rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>  | 
 | 31 | +	<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>  | 
 | 32 | +	<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>  | 
15 | 33 | 	<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>  | 
 | 34 | +	<rule ref="category/java/bestpractices.xml/UseEnumCollections"/>  | 
16 | 35 | 	<rule ref="category/java/bestpractices.xml/UseStandardCharsets"/>  | 
 | 36 | +	<rule ref="category/java/bestpractices.xml/UseTryWithResources"/>  | 
17 | 37 | 
 
  | 
18 | 38 | 	<!-- Native code is platform dependent; Loading external native libs might pose a security threat -->  | 
19 | 39 | 	<rule ref="category/java/codestyle.xml/AvoidUsingNativeCode"/>  | 
20 | 40 | 	<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>  | 
 | 41 | +	<rule ref="category/java/codestyle.xml/LambdaCanBeMethodReference"/>  | 
21 | 42 | 	<rule ref="category/java/codestyle.xml/NoPackage"/>  | 
22 | 43 | 	<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>  | 
 | 44 | +	<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>  | 
23 | 45 | 
 
  | 
24 | 46 | 	<rule ref="category/java/design.xml">  | 
25 | 47 | 		<!-- Sometimes abstract classes have just fields -->  | 
 | 
76 | 98 | 
 
  | 
77 | 99 | 		<!-- Limit too low -->  | 
78 | 100 | 		<exclude name="UseObjectForClearerAPI"/>  | 
79 |  | - | 
80 |  | -		<!-- Handled by checkstyle -->  | 
81 |  | -		<exclude name="UseUtilityClass"/>  | 
82 | 101 | 	</rule>  | 
83 | 102 | 
 
  | 
84 | 103 | 	<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts">  | 
 | 
114 | 133 | 		</properties>  | 
115 | 134 | 	</rule>  | 
116 | 135 | 
 
  | 
 | 136 | +	<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>  | 
 | 137 | +	<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>  | 
 | 138 | +	<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>  | 
117 | 139 | 	<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>  | 
118 | 140 | 	<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>  | 
119 | 141 | 	<rule ref="category/java/errorprone.xml/ComparisonWithNaN"/>  | 
120 | 142 | 	<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>  | 
121 | 143 | 	<rule ref="category/java/errorprone.xml/DontImportSun"/>  | 
 | 144 | +	<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>  | 
 | 145 | +	<rule ref="category/java/errorprone.xml/EqualsNull"/>  | 
 | 146 | +	<rule ref="category/java/errorprone.xml/IdempotentOperations"/>  | 
 | 147 | +	<rule ref="category/java/errorprone.xml/ImplicitSwitchFallThrough"/>  | 
 | 148 | +	<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>  | 
 | 149 | +	<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>  | 
 | 150 | +	<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>  | 
122 | 151 | 	<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>  | 
 | 152 | +	<rule ref="category/java/errorprone.xml/MoreThanOneLogger"/>  | 
 | 153 | +	<rule ref="category/java/errorprone.xml/NonStaticInitializer"/>  | 
 | 154 | +	<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>  | 
 | 155 | +	<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance"/>  | 
 | 156 | +	<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>  | 
123 | 157 | 	<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>  | 
 | 158 | +	<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>  | 
124 | 159 | 
 
  | 
125 | 160 | 
 
  | 
126 | 161 | 	<rule ref="category/java/multithreading.xml">  | 
127 |  | -		<!-- Just bloats code -->  | 
 | 162 | +		<!-- Just bloats code; improved in JEP-491/Java 24+ -->  | 
128 | 163 | 		<exclude name="AvoidSynchronizedAtMethodLevel"/>  | 
129 | 164 | 
 
  | 
130 | 165 | 		<!-- NOPE -->  | 
 | 
159 | 194 | 	</rule>  | 
160 | 195 | 
 
  | 
161 | 196 | 	<rule ref="category/java/security.xml"/>  | 
 | 197 | + | 
 | 198 | +	<rule name="VaadinNativeHTMLUnsafe"  | 
 | 199 | +		language="java"  | 
 | 200 | +		message="Unescaped native HTML is unsafe and will result in XSS vulnerabilities"  | 
 | 201 | +		class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" >  | 
 | 202 | +		<description>  | 
 | 203 | +			Do not used native HTML! Use Vaadin layouts and components to create required structure.  | 
 | 204 | +			If you are 100% sure that you escaped the value properly and you have no better options you can suppress this.  | 
 | 205 | +		</description>  | 
 | 206 | +		<priority>2</priority>  | 
 | 207 | +		<properties>  | 
 | 208 | +			<property name="xpath">  | 
 | 209 | +				<value>  | 
 | 210 | +<![CDATA[  | 
 | 211 | +//ConstructorCall[pmd-java:typeIs('com.vaadin.flow.component.Html')] |  | 
 | 212 | +//MethodCall[@MethodName='setAttribute' and //ImportDeclaration[starts-with(@PackageName,'com.vaadin')]]/ArgumentList/StringLiteral[1][contains(lower-case(@Image),'html')]  | 
 | 213 | +]]>  | 
 | 214 | +				</value>  | 
 | 215 | +			</property>  | 
 | 216 | +		</properties>  | 
 | 217 | +	</rule>  | 
162 | 218 | </ruleset>  | 
0 commit comments