Comments (3)
Back in PMD 6.55.0 if, the container class had any of the ignored annotations, all methods were ignored (and therefore the @Nested
implied plurals()
was not flagged).
This behavior was removed in PMD 7.0.0. Based on the documentation for the rule and existing tests, this behavior was not intended, and actually a false-negative. Moreover, @MethodSource
doesn't impose any requirements on method visibility that I am aware of, unlike @Test
which under JUnit 5 expects package-private to be used prominently.
from pmd.
Test methods default to package-private because visibility isn't much of a concern with tests (there's little inheritance and as non-production code this isn't critical, anyway), so readability (i.e. no clutter, no /* default */
comment) trumps minimal visibility.
IMO that reasoning not just applies to test methods, but also nested test classes, methods that supply arguments to parameterized tests, and any other goodie that has been added (in JUnit 5).
If PMD is forcing users to tweak its default rules for test classes, I think that's unfortunate, especially because complex XPath expressions have to be used (targeting the (outer) test class name, but also including any nested test classes). Many projects adhere to Maven's file system structure (i.e. separation of test classes in src/test
vs. src/main
); it would be really great if PMD allowed exclusions based on that distinction.
from pmd.
@Wolf2323 you can make the method plurals()
private. See also #4975, which has exactly this example. PMD 7.2.0 won't warn about such private methods anymore.
from pmd.
Related Issues (20)
- [java] LooseCoupling - false-positive for Stack, if implementation methods of stack actually used HOT 3
- [java] FinalFieldCouldBeStatic - false-positive for access of super class field
- [java] UseUtilityClass implementation hardcodes a message instead of using the on defined in the XML
- [java] Make PreserveStackTraceRule allowedGetters configurable
- [java] Exception applying rule ConfusingArgumentToVarargsMethod HOT 3
- [java] FormalParameterNamingConventions should accept unnamed parameters by default
- [java] PMD 7.x throws stack overflow in `TypeOps$ProjectionVisitor` while parsing a Java class HOT 1
- [java] SwitchDensity reports violation even though density is low HOT 4
- [java] False positive CheckResultSet with ResultSet.next() in a while loop
- Set appropriate log level in pmd-maven-plugin HOT 1
- Remove extraneous log lines in pmd-maven-plugin HOT 1
- Impractical to fail build on violation HOT 1
- [java] UnusedPrivateMethod false-positive used in method reference HOT 4
- [core] Add fluent API to report violations
- [java] Parsing failed in ParseLock#doParse(): IndexOutOfBoundsException HOT 3
- [java] CloseResource - false-positive on Pattern Matching with instanceof
- [java] LambdaCanBeMethodReference - false-positive on overloaded methods HOT 1
- [java] java.lang.StackOverflowError at TypeOps$RecursionStop.recurseIfNotDone HOT 1
- [java] LocalVariableCouldBeFinal false positive with try/catch
- [java] UnusedPrivateMethod for Generics & Overloads
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pmd.