SonarQube C#
  1. SonarQube C#
  2. SONARCS-391

Allow to set parameters for StyleCop rules

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      I have a need to configure the StyleCop rule: "Field names must not use hungarian notation" from within the Sonar profiles in order to specify some business oriented prefix for a given application.

      Could you please allow us to set such StyleCop rules parameters?

        Issue Links

          Activity

          Hide
          Fabrice Bellingard added a comment -

          I guess you've talked about that with Alexandre, right? If not, then please go first on the user mailing-list to discuss about your problem before creating a ticket.

          Show
          Fabrice Bellingard added a comment - I guess you've talked about that with Alexandre, right? If not, then please go first on the user mailing-list to discuss about your problem before creating a ticket.
          Hide
          Thomas PIERRAIN added a comment -

          You guess right. I've created this JIRA ticket following Alexandre's advice.

          Show
          Thomas PIERRAIN added a comment - You guess right. I've created this JIRA ticket following Alexandre's advice.
          Hide
          Alexandre Victoor added a comment -

          Actually I wonder if these parameters should not rather be plugin parameters instead of rules parameters.
          In the stylecop conf files they are analyzers parameters and so they are applied to a bunch of rules...
          Tell me what do you thing?

          Show
          Alexandre Victoor added a comment - Actually I wonder if these parameters should not rather be plugin parameters instead of rules parameters. In the stylecop conf files they are analyzers parameters and so they are applied to a bunch of rules... Tell me what do you thing?
          Hide
          Thomas PIERRAIN added a comment -

          I'm not very comfortable to answer your question since I'm not aware of all the implementation details here. But I will try.

          What is important for me (from the most to the less important):

          • To be able to declare Hungarian notation prefix exceptions per project
          • To prevent people to use what you will develop here in order to change/hack other stylecop rules in the same time
          • To be able to declare Hungarian notation prefix exceptions for a set of projects (remember: duplication is evil

          Thus would it be feasible, before the sonar-csharp-stylecop-plugin runs its analysis, to make it merge the stylecop rules of the official sonar server profile with the hungarian notation prefix exceptions that could be found within any existing Settings.StyleCop file located next to the project/solution to be analyzed?

          Show
          Thomas PIERRAIN added a comment - I'm not very comfortable to answer your question since I'm not aware of all the implementation details here. But I will try. What is important for me (from the most to the less important): To be able to declare Hungarian notation prefix exceptions per project To prevent people to use what you will develop here in order to change/hack other stylecop rules in the same time To be able to declare Hungarian notation prefix exceptions for a set of projects (remember: duplication is evil Thus would it be feasible, before the sonar-csharp-stylecop-plugin runs its analysis, to make it merge the stylecop rules of the official sonar server profile with the hungarian notation prefix exceptions that could be found within any existing Settings.StyleCop file located next to the project/solution to be analyzed?
          Hide
          Alexandre Victoor added a comment -

          Done
          See property sonar.stylecop.analyzers.settings described in the advanced section of the StyleCop configuration page

          Show
          Alexandre Victoor added a comment - Done See property sonar.stylecop.analyzers.settings described in the advanced section of the StyleCop configuration page
          Hide
          Thomas PIERRAIN added a comment -

          It just works. Thank you!

          But since StyleCop automatically creates files with name "Settings.StyleCop", would it be feasible for the sonar.stylecop plugin to automatically exploit any "Settings.StyleCop" found next to every .csproj or upon (1) without forcing us to specify a value (always the same) for the "sonar.stylecop.analyzers.settings" configuration key? Indeed, this key should be used only for very specific cases where the StyleCop configuration files would have been renamed (very rare).

          What do you think?

          (1): following the Stylecop way of merging its configuration files: http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/25/sharing-source-analysis-settings-across-projects.aspx

          Show
          Thomas PIERRAIN added a comment - It just works. Thank you! But since StyleCop automatically creates files with name "Settings.StyleCop", would it be feasible for the sonar.stylecop plugin to automatically exploit any "Settings.StyleCop" found next to every .csproj or upon (1) without forcing us to specify a value (always the same) for the "sonar.stylecop.analyzers.settings" configuration key? Indeed, this key should be used only for very specific cases where the StyleCop configuration files would have been renamed (very rare). What do you think? (1): following the Stylecop way of merging its configuration files: http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/25/sharing-source-analysis-settings-across-projects.aspx
          Hide
          Fabrice Bellingard added a comment -

          Tested the new "sonar.stylecop.analyzers.settings" parameter, and added IT.

          @Alexandre: I've figured out that StyleCop rules are not configurable at all in Sonar, because the "rules.xml" file of the plugin does not specify parameters for each rule. Do you know why?

          Show
          Fabrice Bellingard added a comment - Tested the new "sonar.stylecop.analyzers.settings" parameter, and added IT. @Alexandre: I've figured out that StyleCop rules are not configurable at all in Sonar, because the "rules.xml" file of the plugin does not specify parameters for each rule. Do you know why?

            People

            • Assignee:
              Alexandre Victoor
              Reporter:
              Anonymous
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: