-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Enable more style checking analyzers #78414
Comments
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsThere are several analyzers that check for code style that runtime repo could benefit from if enabled. They are not too pedantic and could help to make the large codebase more readable. For example
|
@stephentoub thoughts on this? Seems reasonable, but not for 8.0 at this point. Let's move this to 9.0 and do it early. |
Most of these look fine. Someone can try (one at a time, please), and we can look at the impact to see if there's anything unexpected we don't like. |
This is labeled analyzer but there's no analyzer work here, right? isn't it just a regular work item in area-meta? |
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsThere are several analyzers that check for code style that runtime repo could benefit from if enabled. They are not too pedantic and could help to make the large codebase more readable. For example
|
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsThere are several analyzers that check for code style that runtime repo could benefit from if enabled. They are not too pedantic and could help to make the large codebase more readable. For example
|
@jeffschwMSFT I moved this back to area-Meta as there's no infrastructure work necessary for this. |
if anyone wants to look at these, start by editing eng\CodeAnalysis.src.globalconfig and/or eng\CodeAnalysis.test.globalconfig then open things up in VS and build. |
@danmoseley - do we typically prefer these as warnings or errors? I can see value in both. |
@artl93 i don't know what current thinking is in this repo - @stephentoub can say. In general we've discussed that (a) we don't like PR validation to fail merely because of a trivial style issue leaving us with no test results and (b) we like to be able to code locally without the build failing merely because of trivial style issues in work that's not finished. The @jaredpar approach I believe is for them to be warnings locally and in some but not all PR validation flavors. Not sure what thinking is in this repo. |
The way we've approach code style warning is:
The rationale for this setup is ... The goal of CI should be to provide the maximum amount of information possible, in the fastest amount of time, for any given change. As such do not run code style checks on the paths that feed to unit tests. It's potentially introducing warnings that risk promoting to errors and stopping tests from running (as well as impacting build time). There is no reason a trailing space should stop a unit test from even running. This is also why the same jobs disable As for local developer setup there was a lot of back and forth about the tradeoffs for running style checks locally. There is a measurable perf hit for some rules, particularly when dealing with repos the size of roslyn / runtime. After discussion we decided most devs were more comfortable with having info level diagnostics only in VS, but nothing in the command line. 99% of time VS is just going to auto-format it the correct way any who. Devs who want to have it run locally can specify an environment variable that enables all that checking on their machine (very small minority do this) Another way to think about all this is a sure fire way to upset developers enough to reach for their pitchforks is ...:
Hope that helps. |
Thanks! That totally makes sense. How would this practically translate to changes I would need to make the to globalgonfig file, as I am working on in #94100? Would I just be removing the line in eng/CodeAnalysis.src.globalconfig, and then leaving eng/CodeAnalysis.test.globalconfig alone? |
One more thing - (again, displaying my ignorance) I'm on a Mac, so I use VS on Windows by exception, not as a rule (though, that's likely to change). Is there a way to see all the potential errors my global change will cause across all projects? Looking at the repo and docs, it seems I'd have to load them individually. FWIW - is there a way to get this same error information to show on the command line, or (for bonus points) in VS Code? |
Thus far in runtime, we've taken a different approach from what Jared outlines: all analyzer rules we've explicitly decided to get clean against are enabled as warnings (which are then promoted by default via warnings-as-errors) and run as such everywhere, command-line, in VS, and in CI. If a developer doesn't want them as errors locally, they disable warnings-as-errors. |
We've tried to be explicit about every analyzer, so you wouldn't remove a line from the globalconfig, you'd just change the severity on the line that's already there (or if for some reason we're missing a line for the analyzer in question, add it). |
You can just build from root but with warnings-as-errors disabled, e.g.
|
Do you all do this on test legs too? When we were designing our system the only item that had universal agreement was to turn off analyzers and |
There are several analyzers that check for code style that runtime repo could benefit from if enabled. They are not too pedantic and could help to make the large codebase more readable.
For example
The text was updated successfully, but these errors were encountered: