You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -158,6 +159,17 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
158
159
]]></value>
159
160
</property>
160
161
</properties>
162
+
<example>
163
+
<![CDATA[
164
+
public final class DirectAccessToStaticFields {
165
+
private static int num = 1;
166
+
167
+
public static int number() {
168
+
return num;
169
+
}
170
+
}
171
+
]]>
172
+
</example>
161
173
</rule>
162
174
<rulename="AvoidAccessToStaticMembersViaThis"message="Static members should be accessed in a static way [CLASS_NAME.FIELD_NAME], not via instance reference."language="java"class="net.sourceforge.pmd.lang.rule.XPathRule">
163
175
<description>
@@ -191,10 +203,9 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
191
203
and not (
192
204
MethodDeclarator[
193
205
count(FormalParameters/FormalParameter)=1
194
-
and @Image='main'
195
206
and FormalParameters/FormalParameter[1]/Type/ReferenceType/ClassOrInterfaceType[@Image='String']
196
207
and FormalParameters/FormalParameter[@Varargs='true']
197
-
] and not(ResultType/Type)
208
+
] and not(ResultType/Type) and @Name='main'
198
209
)
199
210
] and (
200
211
Annotation/MarkerAnnotation/Name[@Image!='BeforeClass' and @Image!='AfterClass'
@@ -219,64 +230,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
219
230
</property>
220
231
</properties>
221
232
</rule>
222
-
<rulename="ReturnEmptyCollectionRatherThanNull"language="java"class="net.sourceforge.pmd.lang.rule.XPathRule"message="Returned null collection was found (NullCollection).">
223
-
<description>
224
-
Any method that returns an collection (i.e. an array or a List), it is better to return
<rulename="JUnit5TestShouldBePackagePrivate"language="java"class="net.sourceforge.pmd.lang.rule.XPathRule"message="JUnit 5 tests should be package-private">
242
-
<description><![CDATA[
243
-
Reports JUnit 5 test classes and methods that are not package-private.
244
-
Contrary to JUnit 4 tests, which required public visibility to be run by the engine,
245
-
JUnit 5 tests can also be run if they're package-private. Marking them as such
246
-
is a good practice to limit their visibility.
247
-
Test methods are identified as those which use `@Test`, `@RepeatedTest`,
248
-
`@TestFactory`, `@TestTemplate` or `@ParameterizedTest`.
249
-
]]></description>
250
-
<priority>3</priority>
251
-
<properties>
252
-
<propertyname="version"value="2.0"/>
253
-
<!--Solve priority confict-->
254
-
<propertyname="xpath">
255
-
<value><![CDATA[
256
-
//ClassOrInterfaceDeclaration[
257
-
(: a Junit 5 test class, ie, it has methods with the annotation :)
0 commit comments