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

FP S3749 should not raise issue for fields injected via constructor

    Details

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

      Description

      Rule RSPEC-3749 will raise an issue in the case of injection via constructor : 

       

      @Controller
      class A {
        private Environment env;
        private YYYAdaptor yyyAdaptor;
        private JAXBContext jaxbContext;
      
        @Autowired
        public YYYResource(Environment env, YYYAdaptor yyyAdaptor,
            @Qualifier("YYYYReq") JAXBContext jaxbContext) {
      
          this.env = env;
          this.yyyAdaptor = yyyAdaptor;
          this.jaxbContext = jaxbContext;
        }
      } 

      this goes in contradiction with RSPEC-4288 which recommends to use constructor injection. 

      Therefore no issue should be raised on field injected via constructors.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tibor.blenessy Tibor Blenessy
                Reporter:
                nicolas.peru Nicolas Peru
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: