Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-3748

When activating a rule it should be possible to define the scope : unit test code, source code or both

    XMLWordPrintable

    Details

      Description

      Here are the use cases I want to cover:

      • I'm searching for rules dedicated to tests (most probably thanks to a "test" tag) in order to activate them on my test files.
        • Example: "Use JUnit 4 API instead of JUnit 3" or "A test method should have at least one assertion"
      • I want to apply all available naming rules to both source and test code, but with some differences for some rules
        • Example: for the rule that checks method names, I want to be able to set a different parameter in order to follow one convention on source code (camelcase) and another convention (using underscore).
      • When I activate a rule, if it is dedicated to test, I should not be able to activate it on source code (like checking for assertions). But on the other way, if the rule is generic, then by default activating this rule should be first suggested on source code only.
      • Bulk actions on rules found in the Coding Rules space should help me to deal with activation on those scopes

      In terms of API, language plugins should be able:

      • to declare if a rule applies only to source code, test code or both (default)
      • to ask for active rules on source code and active rules on test code, in order to run their scan twice on a separate set of files (sources and tests)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              szubster Tomasz Szuba
              Votes:
              39 Vote for this issue
              Watchers:
              25 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: