Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings as Errors for test projects #4366

Merged
merged 2 commits into from
Dec 16, 2020

Conversation

bdukes
Copy link
Contributor

@bdukes bdukes commented Dec 15, 2020

This turns off the documentation rules for StyleCop and turns on Warnings as Errors for all test projects

@valadas valadas added this to the 9.8.1 milestone Dec 16, 2020
Copy link
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing it builds after the rebase, this looks good to me.

@valadas valadas merged commit df2e3f1 into dnnsoftware:develop Dec 16, 2020
@bdukes bdukes deleted the dev-cleanup-test branch December 22, 2020 14:54
@daguiler
Copy link
Contributor

daguiler commented Jan 5, 2021

Hi @bdukes
the solution doesn't build anymore in Visual Studio bacause of this. Am I missing something?

@bdukes
Copy link
Contributor Author

bdukes commented Jan 5, 2021

@daguiler it builds fine for me. What errors are you getting? Are you on the latest develop?

@daguiler
Copy link
Contributor

daguiler commented Jan 5, 2021

I am on latest develop, and I'm getting errors because of all the broken rules in the test projects.
Are you not getting the same?

image

@bdukes
Copy link
Contributor Author

bdukes commented Jan 5, 2021

No, those should be suggestions rather than warnings because of the configuration in

# SA1600: Elements should be documented
dotnet_diagnostic.SA1600.severity = none
# SA1309: Field names should not begin with underscore
dotnet_diagnostic.SA1309.severity = suggestion
# SA1117: Parameters should be on same line or separate lines
dotnet_diagnostic.SA1117.severity = suggestion
# SA1402: File may only contain a single type
dotnet_diagnostic.SA1402.severity = suggestion
# SA1616: Element return value documentation should have text
dotnet_diagnostic.SA1616.severity = suggestion
# Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules'
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = suggestion
# CA2100: Review SQL queries for security vulnerabilities
dotnet_diagnostic.CA2100.severity = suggestion
# SA1401: Fields should be private
dotnet_diagnostic.SA1401.severity = suggestion
# SA1512: Single-line comments should not be followed by blank line
dotnet_diagnostic.SA1512.severity = suggestion
# Default severity for analyzer diagnostics with category 'StyleCop.CSharp.ReadabilityRules'
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.ReadabilityRules.severity = suggestion
# SA0001: XML comment analysis is disabled due to project configuration
dotnet_diagnostic.SA0001.severity = silent
# SA1303: Const field names should begin with upper-case letter
dotnet_diagnostic.SA1303.severity = suggestion
# SA1300: Element should begin with upper-case letter
dotnet_diagnostic.SA1300.severity = suggestion
# SA1306: Field names should begin with lower-case letter
dotnet_diagnostic.SA1306.severity = suggestion
# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = suggestion
# SA1311: Static readonly fields should begin with upper-case letter
dotnet_diagnostic.SA1311.severity = suggestion
# Default severity for analyzer diagnostics with category 'StyleCop.CSharp.LayoutRules'
dotnet_analyzer_diagnostic.category-StyleCop.CSharp.LayoutRules.severity = suggestion
# CS0618: Type or member is obsolete
dotnet_diagnostic.CS0618.severity = none
# SA1312: Variable names should begin with lower-case letter
dotnet_diagnostic.SA1312.severity = suggestion
# SA1210: Using directives should be ordered alphabetically by namespace
dotnet_diagnostic.SA1210.severity = suggestion
# CS0114: Member hides inherited member; missing override keyword
dotnet_diagnostic.CS0114.severity = suggestion
# SA1202: Elements should be ordered by access
dotnet_diagnostic.SA1202.severity = suggestion
# SA1310: Field names should not contain underscore
dotnet_diagnostic.SA1310.severity = suggestion
# SA1313: Parameter names should begin with lower-case letter
dotnet_diagnostic.SA1313.severity = suggestion
# SA1314: Type parameter names should begin with T
dotnet_diagnostic.SA1314.severity = suggestion

@bdukes
Copy link
Contributor Author

bdukes commented Jan 5, 2021

What version of Visual Studio are you using? I bet it's a fairly new feature to read severity for those rules through .editorconfig.

@daguiler
Copy link
Contributor

daguiler commented Jan 5, 2021

mm.. I'm still on 2017 Enterprise

@daguiler
Copy link
Contributor

daguiler commented Jan 5, 2021

According to this article, VS 2017 supports .editorconfig files. I'll dig a bit more.

@bdukes
Copy link
Contributor Author

bdukes commented Jan 5, 2021

The Analyzer configuration documentation says

Starting in Visual Studio 2019 version 16.3, you can configure the severity of analyzer rules, or diagnostics, in an EditorConfig file, from the light bulb menu, and from the error list.

@daguiler
Copy link
Contributor

daguiler commented Jan 5, 2021

I had an update available for my 2017 version (from 15.9.23 to 15.9.30), but unfortunately it didn't help with this issue.
So I guess I will have to undo this change in my local environment from now on every time I want to build the solution :-(

@bdukes
Copy link
Contributor Author

bdukes commented Jan 5, 2021

If you'd like to submit a change which would work for VS 2017, we'd happily accept it. The best option would be, of course, to resolve the warnings, but that's rather time consuming, which is why we haven't done it 😄

A partial option would be to add a new stylecop.json file for tests which loosens the strictness of the rules (specifically, you can disable the documentation rules), but fix the other issues which can't be controlled via stylecop.json.

The other option is to introduce a .ruleset file which disables the rules and reference that from the test projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants