A RetroSearch Logo

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

Search Query:

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

[java] Drop AtLeastOneConstructor · Issue #1609 · pmd/pmd · GitHub

Affects PMD Version:

1.04+

Rule:

AtLeastOneConstructor

Description:

PMD complains when no explicit constructor is declared for a class. Including JUnit tests.

Note that JUnit expects tests to feature a public, 0-ary constructor, or else it throws an initialization error. So treating JUnit tests as utility classes with private constructors is not an option.

One could explicitly declare an empty constructor for each JUnit test, but that's wasteful. In any case, Java automatically creates an implicit constructor, so there's really no need for PMD to generate noise about this.

As a workaround, I am disabling the AtLeastOneConstructor rule entirely, in my rulesets.xml:

<rule ref="category/java/codestyle.xml">
    <exclude name="AtLeastOneConstructor" />
</rule>

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

Gradle


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