A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1164 below:

[java] ClassNamingConventions suggests to add Util for class containing only static constants · Issue #1164 · pmd/pmd · GitHub

Affects PMD Version:

6.4.0

Rule:
ClassNamingConventions

Description:

A class containg only static constants triggers violation that it should be renamed to end with either Utils or Helper

Code Sample demonstrating the issue:

public final class StringConstants {
    public static final String YES = "Y";
    public static final String NO = "N";
    private StringConstants(){
    }
}

Error Message:

The utility class name 'StringConstants' doesn't match '[A-Z][a-zA-Z0-9]+(Utils?|Helper)'

Running PMD through: Maven

Other Info

You can reproduce this issue in the unit test by adding this entry

<test-code>
        <description>Class containing constants</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
            public final class StringConstants {
                public static final String YES = "Y";
                public static final String NO = "N";
                private StringConstants(){
                }
            }
            ]]></code>
    </test-code>

to file : ClassNamingConventions.xml


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4