X Tutup
The Wayback Machine - https://web.archive.org/web/20201219231242/https://github.com/PowerShell/PowerShell/pull/13963
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

Add StyleCop.Analyzers package #13963

Merged
merged 3 commits into from Nov 18, 2020
Merged

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.

@xtqqczze

This comment has been hidden.

@xtqqczze
Copy link
Contributor Author

@xtqqczze 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
@xtqqczze
Copy link
Contributor Author

@xtqqczze xtqqczze commented Nov 11, 2020

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

@xtqqczze xtqqczze marked this pull request as ready for review Nov 11, 2020
@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Nov 11, 2020

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 xtqqczze:add-StyleCop-package branch 2 times, most recently from 86e6e2c to 82d11a8 Nov 11, 2020
.globalconfig Outdated Show resolved Hide resolved
@xtqqczze
Copy link
Contributor Author

@xtqqczze xtqqczze commented Nov 12, 2020

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

@xtqqczze xtqqczze commented Nov 12, 2020

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

@iSazonov iSazonov commented Nov 12, 2020

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

@xtqqczze xtqqczze commented Nov 18, 2020

@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

@iSazonov iSazonov commented Nov 18, 2020

@xtqqczze How much are we slowing down the build?

@xtqqczze
Copy link
Contributor Author

@xtqqczze xtqqczze commented Nov 18, 2020

@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

@xtqqczze xtqqczze commented Nov 18, 2020

@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 merged commit 44a701f into PowerShell:master Nov 18, 2020
32 checks passed
32 checks passed
Analyze (csharp)
Details
CodeQL No new alerts
Details
CodeFactor No issues found.
Details
PowerShell-CI-linux Build #PR-13963-20201111.04 succeeded
Details
PowerShell-CI-linux (Build for Linux linux Build) Build for Linux linux Build succeeded
Details
PowerShell-CI-linux (CodeCoverage and Test Packages CodeCoverage and Test Packages) CodeCoverage and Test Packages CodeCoverage and Test Packages succeeded
Details
PowerShell-CI-linux (Test for Linux Linux Test - ElevatedPesterTests - CI) Test for Linux Linux Test - ElevatedPesterTests - CI succeeded
Details
PowerShell-CI-linux (Test for Linux Linux Test - ElevatedPesterTests - Others) Test for Linux Linux Test - ElevatedPesterTests - Others succeeded
Details
PowerShell-CI-linux (Test for Linux Linux Test - UnelevatedPesterTests - CI) Test for Linux Linux Test - UnelevatedPesterTests - CI succeeded
Details
PowerShell-CI-linux (Test for Linux Linux Test - UnelevatedPesterTests - Others) Test for Linux Linux Test - UnelevatedPesterTests - Others succeeded
Details
PowerShell-CI-linux (Test for Linux Verify xUnit Results) Test for Linux Verify xUnit Results succeeded
Details
PowerShell-CI-macos Build #PR-13963-20201111.04 succeeded
Details
PowerShell-CI-macos (Build for macOS macOS Build) Build for macOS macOS Build succeeded
Details
PowerShell-CI-macos (CodeCoverage and Test Packages CodeCoverage and Test Packages) CodeCoverage and Test Packages CodeCoverage and Test Packages succeeded
Details
PowerShell-CI-macos (Test for macOS Verify xUnit Results) Test for macOS Verify xUnit Results succeeded
Details
PowerShell-CI-macos (Test for macOS mac Test - ElevatedPesterTests - CI) Test for macOS mac Test - ElevatedPesterTests - CI succeeded
Details
PowerShell-CI-macos (Test for macOS mac Test - ElevatedPesterTests - Others) Test for macOS mac Test - ElevatedPesterTests - Others succeeded
Details
PowerShell-CI-macos (Test for macOS mac Test - UnelevatedPesterTests - CI) Test for macOS mac Test - UnelevatedPesterTests - CI succeeded
Details
PowerShell-CI-macos (Test for macOS mac Test - UnelevatedPesterTests - Others) Test for macOS mac Test - UnelevatedPesterTests - Others succeeded
Details
PowerShell-CI-static-analysis Build #PR-13963-20201111.04 succeeded
Details
PowerShell-CI-static-analysis (Markdown and Common Tests) Markdown and Common Tests succeeded
Details
PowerShell-CI-static-analysis (Secret Scan) Secret Scan succeeded
Details
PowerShell-CI-windows Build #PR-13963-20201111.04 succeeded
Details
PowerShell-CI-windows (Build for Windows Windows Build) Build for Windows Windows Build succeeded
Details
PowerShell-CI-windows (Packaging for Windows Windows Packaging) Packaging for Windows Windows Packaging succeeded
Details
PowerShell-CI-windows (Test for Windows Verify xUnit Results) Test for Windows Verify xUnit Results succeeded
Details
PowerShell-CI-windows (Test for Windows Windows Test - ElevatedPesterTests - CI) Test for Windows Windows Test - ElevatedPesterTests - CI succeeded
Details
PowerShell-CI-windows (Test for Windows Windows Test - ElevatedPesterTests - Others) Test for Windows Windows Test - ElevatedPesterTests - Others succeeded
Details
PowerShell-CI-windows (Test for Windows Windows Test - UnelevatedPesterTests - CI) Test for Windows Windows Test - UnelevatedPesterTests - CI succeeded
Details
PowerShell-CI-windows (Test for Windows Windows Test - UnelevatedPesterTests - Others) Test for Windows Windows Test - UnelevatedPesterTests - Others succeeded
Details
WIP Ready for review
Details
license/cla All CLA requirements met.
Details
@xtqqczze xtqqczze deleted the xtqqczze:add-StyleCop-package branch Nov 18, 2020
@xtqqczze
Copy link
Contributor Author

@xtqqczze xtqqczze commented Nov 20, 2020

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)

@msftbot
Copy link

@msftbot msftbot bot commented Dec 15, 2020

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

Handy links:

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

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.
X Tutup