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

Rule S4605 is not detected with @SpringBootApplication

    Details

    • Type: False Negative
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.14
    • Fix Version/s: 6.15.1
    • Component/s: Rules

      Description

      Implementation of RSPEC-4605 is detected for @ComponentScan but not for @SpringBootApplication.

      The following code having the basePackages value "com.mathiric.house.domain" is ignored and only the name of the package is taken into account, leading to a FN.

       
      Application code

      package com.mathiric.house; // mistakenly taken by the rule
      
      import org.springframework.boot.SpringApplication;
      import org.springframework.boot.autoconfigure.SpringBootApplication;
      
      @SpringBootApplication(basePackages = "com.mathiric.house.domain") // not taken into account, wrong base package
      public class HouseApplication { }
      

      Controller code

      package com.mathiric.house.controller;
      
      import org.springframework.web.bind.annotation.*;
      
      @RestController
      public class HouseController { } // issue expected, as controllers are expected to be "com.mathiric.house.domain"
      

      If possible, we should rely on the new SQ API to report secondary in another file, for all the cases covered by these rule!

      • Primary: The Controller class
      • Secondary(-ies): the declaration of covered packages in other files

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michael.gumowski Michael Gumowski
                Reporter:
                richard.mathis Richard Mathis
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: