• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmd / pmd / 167

19 Sep 2025 02:08PM UTC coverage: 78.657% (+0.003%) from 78.654%
167

push

github

adangel
[java] Fix #5878: DontUseFloatTypeForLoopIndices now checks the UpdateStatement as well (#6024)

18176 of 23959 branches covered (75.86%)

Branch coverage included in aggregate %.

39694 of 49614 relevant lines covered (80.01%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ExcessivePublicCountRule.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.java.rule.design;
6

7
import static net.sourceforge.pmd.lang.java.ast.JModifier.FINAL;
8
import static net.sourceforge.pmd.lang.java.ast.JModifier.PUBLIC;
9
import static net.sourceforge.pmd.lang.java.ast.JModifier.STATIC;
10

11
import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration;
12
import net.sourceforge.pmd.lang.java.ast.ASTTypeDeclaration;
13
import net.sourceforge.pmd.lang.java.ast.ModifierOwner;
14
import net.sourceforge.pmd.lang.java.rule.internal.AbstractJavaCounterCheckRule;
15

16
/**
17
 * Rule attempts to count all public methods and public attributes
18
 * defined in a class.
19
 *
20
 * <p>If a class has a high number of public operations, it might be wise
21
 * to consider whether it would be appropriate to divide it into
22
 * subclasses.</p>
23
 *
24
 * <p>A large proportion of public members and operations means the class
25
 * has high potential to be affected by external classes. Furthermore,
26
 * increased effort will be required to thoroughly test the class.
27
 * </p>
28
 *
29
 * @author aglover
30
 */
31
public class ExcessivePublicCountRule extends AbstractJavaCounterCheckRule<ASTTypeDeclaration> {
32

33
    public ExcessivePublicCountRule() {
34
        super(ASTTypeDeclaration.class);
1✔
35
    }
1✔
36

37
    @Override
38
    protected int defaultReportLevel() {
39
        return 45;
1✔
40
    }
41

42
    /**
43
     * @deprecated since 7.18.0. This method is not used anymore and shouldn't be implemented.
44
     */
45
    @Deprecated
46
    protected boolean isViolation(ASTTypeDeclaration node, int reportLevel) {
47
        throw new UnsupportedOperationException("method is deprecated and not supported anymore.");
×
48
    }
49

50
    @Override
51
    protected int getMetric(ASTTypeDeclaration node) {
52
        return node.getDeclarations()
1✔
53
                   .filterIs(ModifierOwner.class)
1✔
54
                   .filter(it -> it.hasModifiers(PUBLIC))
1✔
55
                   // filter out constants
56
                   .filter(it -> !(it instanceof ASTFieldDeclaration && it.hasModifiers(STATIC, FINAL)))
1✔
57
                   .count();
1✔
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc