A RetroSearch Logo

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

Search Query:

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

[java] ImmutableField reports fields annotated with @Value (Spring) · Issue #3981 · pmd/pmd · GitHub

Affects PMD Version:
6.44.0 and 6.45.0

Rule:
ImmutableField
https://pmd.github.io/pmd-6.45.0/pmd_rules_java_design.html#immutablefield

Description:

Similar to the issue #3874, when annotating fields with Spring's @Value annotation, PMD (starting from 6.44.0) will report "the field could be made final. It is only initialized in the declaration or constructor." However, the fields need to be non-final in order for the reflection.

Code Sample demonstrating the issue:

@Configuration
public class SomeConfig {

    @Value("${someConfigValue}")
    private String someConfigField;
}

Expected outcome:

PMD reports a violation for someConfigField, but that's wrong. That's a false positive.

Running PMD through:
CLI and Maven


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