Skip to content

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Nov 2, 2020

Add Roslyn analyzers StyleCop.Analyzers to build and live analysis.

All rules have been disabled except for SA1518.

@ghost ghost assigned TravisEz13 Nov 2, 2020
@xtqqczze

This comment has been minimized.

@xtqqczze
Copy link
Contributor Author

xtqqczze commented Nov 2, 2020

@iSazonov What do you think about adding StyleCop.Analyzers to build and to live analysis?

@xtqqczze xtqqczze changed the title Add StyleCop.Analyzers with all rules disabled Add StyleCop.Analyzers package with all rules disabled Nov 2, 2020
@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 6, 2020
@xtqqczze
Copy link
Contributor Author

We could set SA1518 severity to warning to prevent regressions from #13574.

@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 11, 2020
@xtqqczze xtqqczze marked this pull request as ready for review November 11, 2020 17:41
@iSazonov
Copy link
Collaborator

I think we could do the same as we do for analyzers. Only my concern is increasing time of the build so we could consider to move this (Roslyn analyzers and StyleCop.Analyzers) to separate GitHub check.

@xtqqczze xtqqczze changed the title Add StyleCop.Analyzers package with all rules disabled Add StyleCop.Analyzers package Nov 11, 2020
@xtqqczze xtqqczze force-pushed the add-StyleCop-package branch 2 times, most recently from 86e6e2c to 82d11a8 Compare November 11, 2020 20:18
@xtqqczze
Copy link
Contributor Author

I think we could do the same as we do for analyzers. Only my concern is increasing time of the build so we could consider to move this (Roslyn analyzers and StyleCop.Analyzers) to separate GitHub check.

We should monitor build times, but there is value in running analyzers as part of each build rather then a separate check. One reason is conditionals in the pre-processor, we would need to run the analyzers for each combination of symbols, UNIX, CORECLR etc if we did not run during build.

@xtqqczze
Copy link
Contributor Author

I think we could do the same as we do for analyzers. Only my concern is increasing time of the build so we could consider to move this (Roslyn analyzers and StyleCop.Analyzers) to separate GitHub check.

We should monitor build times, but there is value in running analyzers as part of each build rather then a separate check. One reason is conditionals in the pre-processor, we would need to run the analyzers for each combination of symbols, UNIX, CORECLR etc if we did not run during build.

Running analyzers during local build also allows contributors to fix issues before submitting a PR.

@iSazonov
Copy link
Collaborator

we would need to run the analyzers for each combination of symbols, UNIX, CORECLR etc if we did not run during build.

We use only UNIX and WINDOWS.

@xtqqczze
Copy link
Contributor Author

@iSazonov Once this PR is merged I can move forward with SAXXXX drafts PRs. If the changes cause issues with build time we can deal with this in the first instance.

@iSazonov
Copy link
Collaborator

@xtqqczze How much are we slowing down the build?

@xtqqczze
Copy link
Contributor Author

@iSazonov It seems build on PowerShell-CI-Windows currently takes around 6 minutes, I've opened test PR #14122 with all analyzers disabled to see whether there is a difference.

@xtqqczze
Copy link
Contributor Author

@iSazonov It appears build time is quite variable, and having analyzers enabled does not measurably slow the build.

In this PR (161ccea) build time was 9m 1s
In #14122 (b0f6e3d) build time was 13m 33s
In #14122 (ddc3a70) build time was 9m 22s

The measurement I have used is the total for PowerShell-CI-windows (Build for Windows Windows Build) (so as to include xUnit build too).

@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Nov 18, 2020
@iSazonov iSazonov merged commit 44a701f into PowerShell:master Nov 18, 2020
@xtqqczze xtqqczze deleted the add-StyleCop-package branch November 18, 2020 19:24
@xtqqczze
Copy link
Contributor Author

Three 3 SA1507 violations were fixed in this PR, but CodeFactor has only reported one issue fixed. If we ignore the fix in tests, it is clear CodeFactor is not checking inside of if UNIX directive.

So if we want to enforce style rules through the entire codebase, we need to keep the StyleCop.Analyzers package that was added in #13963.

Originally posted by @xtqqczze in #14136 (comment)

@ghost
Copy link

ghost commented Dec 15, 2020

🎉v7.2.0-preview.2 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants