Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StyleCop Suppression

Is it possible to suppress StyleCop rules in a more global what... in other words not just using source in-line attributes?

like image 211
Streamhaldo Avatar asked Jan 22 '10 18:01

Streamhaldo


People also ask

How do I get rid of StyleCop?

right-click on a project in Project Explorer. select "StyleCop Settings" on the "Rules" tab of the dialog that opens, uncheck the "C#" root of the Enabled rules tree.

How do I turn off StyleCop rule?

In your StyleCop install, there's a Settings. StyleCop file. You can edit this to turn off rules globally. Drag that file onto the Settings Editor executable in that file to edit it.

How do I configure StyleCop?

Configuring StyleCop is done in two optional steps. First, you can use rule set files to configure which rules are checked and how strongly you feel about them. Second, you can add a stylecop. json file to your project to fine-tune some rules.


1 Answers

You can disable certain stylecop rules with a Settings.StyleCop file. For example there's certain things built into stylecop that doesn't fit with our standard. For example in my Settings.StyleCop file we have:

<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
  <Rules>
    <Rule Name="PrefixLocalCallsWithThis">
      <RuleSettings>
        <BooleanProperty Name="Enabled">False</BooleanProperty>
      </RuleSettings>
    </Rule>
  </Rules>
  <AnalyzerSettings />
</Analyzer>

Such that on a member variable or property we don't have to have "this." for each and every one.

like image 91
McAden Avatar answered Sep 28 '22 17:09

McAden