Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3605

FP in S3305 when field has an initializer

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.10
    • Component/s: Rules
    • Labels:
      None

      Description

      When an @Autowired field contains an initializer, S3305 should not raise an issue, as it is a common pattern used to define a default value.

        @Configuration
        public class InnerConfig {
          @Autowired(required=false)
          private @NonNull List<Thing> things = Collections.emptyList();
          @Bean
          public Foo method() {
            return new Foo(this.x);
          }
        }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                quentin.jaquier Quentin Jaquier
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: