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

OSOE-150: Add PowerShell static code analysis #1

Merged
merged 105 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
2ecf36c
Add Invoke-Analyzer.
sarahelsaig Jul 4, 2022
dbe6e74
Readme documentation.
sarahelsaig Jul 4, 2022
1d058e2
New default settings logic.
sarahelsaig Jul 4, 2022
4b54e71
Add MSBuild targets.
sarahelsaig Jul 4, 2022
be6d2b5
Make `Invoke-Analyzer` output in MSBuild-compatible format.
sarahelsaig Jul 4, 2022
2f8f634
Nicer warning message.
sarahelsaig Jul 4, 2022
ea9e229
Warning no longer needed.
sarahelsaig Jul 5, 2022
8686904
Always MSBuild
sarahelsaig Jul 5, 2022
d3c63b9
Use the error stream.
sarahelsaig Jul 5, 2022
5813903
Major performance improvement.
sarahelsaig Jul 5, 2022
9a73772
Bug fix in `$ForGitHubActions`.
sarahelsaig Jul 5, 2022
63cfe25
Try caching GH output.
sarahelsaig Jul 5, 2022
2694222
No idea what's going on.
sarahelsaig Jul 5, 2022
f35fbe8
More logging.
sarahelsaig Jul 5, 2022
3ede752
More logging.
sarahelsaig Jul 5, 2022
341541b
More logging.
sarahelsaig Jul 5, 2022
fec9f48
More logging.
sarahelsaig Jul 5, 2022
93cd53d
Fix `Find-Recursively` on Linux.
sarahelsaig Jul 5, 2022
ffb5ab8
Remove diagnostic logging.
sarahelsaig Jul 5, 2022
97974ff
Fix warnings in ps1 files.
sarahelsaig Jul 5, 2022
d6bbc82
Use the correct cmdlet to turn path into FileInfo.
sarahelsaig Jul 5, 2022
a047cc0
Use IgnoreExitCode.
sarahelsaig Jul 5, 2022
8c6f33a
IncludeTestSolutions
sarahelsaig Jul 5, 2022
e7690a1
Create test solutions.
sarahelsaig Jul 5, 2022
31e9ebf
Add more tests.
sarahelsaig Jul 5, 2022
558ce0f
Remove temporary diagnostics.
sarahelsaig Jul 5, 2022
f5bf375
Add sln file for nuget publishing.
sarahelsaig Jul 5, 2022
939c9ba
Alter PackagePath for NuGet compatibility.
sarahelsaig Jul 5, 2022
5b91f63
Use a different approach.
sarahelsaig Jul 5, 2022
dff525d
Try a different way to make NuGet work.
sarahelsaig Jul 5, 2022
219176d
Fix wrong group and missing argument.
sarahelsaig Jul 5, 2022
2ee7f50
Use the `publish` from this branch.
sarahelsaig Jul 5, 2022
85dfec1
Update NuGet version.
sarahelsaig Jul 5, 2022
1640328
Make it Windows PowerShell compatible.
sarahelsaig Jul 5, 2022
dfb1b41
Make TestSolutions ignoring more flexible.
sarahelsaig Jul 5, 2022
07992d1
Update called workflow names.
sarahelsaig Jul 6, 2022
1db9158
Improve MSBuild parameterization.
sarahelsaig Jul 6, 2022
4b85f1b
Improve readme.
sarahelsaig Jul 6, 2022
4c113a6
Upgrade PackageReference.
sarahelsaig Jul 6, 2022
25daeab
Fix props file's name casing.
sarahelsaig Jul 6, 2022
5f0d1f6
Attempt to auto-install PSScriptAnalyzer
sarahelsaig Jul 6, 2022
91ce9a2
Clarify readme.
sarahelsaig Jul 6, 2022
c3a92e5
Look for other ps extensions too.
sarahelsaig Jul 6, 2022
0966e91
Merge branch 'issue/OSOE-150' of https://github.com/Lombiq/PowerShell…
sarahelsaig Jul 6, 2022
454fd75
Update Readme.md
sarahelsaig Jul 6, 2022
5648a41
Apply suggestions from code review
sarahelsaig Jul 6, 2022
5c93562
Merge branch 'issue/OSOE-150' of https://github.com/Lombiq/PowerShell…
sarahelsaig Jul 6, 2022
8b33f9f
Only Warning and above (ignore "Information" type results).
sarahelsaig Jul 9, 2022
319650c
Exclusion bug fix.
sarahelsaig Jul 10, 2022
d046a9e
Write GH to stderr.
sarahelsaig Jul 10, 2022
71f3258
Revert "Write GH to stderr."
sarahelsaig Jul 10, 2022
8ec006e
Always use MSBuild
sarahelsaig Jul 10, 2022
2d521cb
Explicit version checking.
sarahelsaig Jul 11, 2022
7f95673
Add VS Code info to readme.
sarahelsaig Jul 11, 2022
02532d3
csproj and readme fixes
sarahelsaig Jul 11, 2022
e212faa
Use Write-FileError for resource mismatch too.
sarahelsaig Jul 11, 2022
a3bde25
This is not needed.
sarahelsaig Jul 11, 2022
926363b
Make tests correctly use solution path.
sarahelsaig Jul 11, 2022
76d6006
Check exact violation count.
sarahelsaig Jul 11, 2022
171be8f
Remove hard coded `..`s.
sarahelsaig Jul 11, 2022
f4c0ca7
Fix installation condition.
sarahelsaig Jul 11, 2022
0b6be6d
Rewrite exit code message.
sarahelsaig Jul 12, 2022
caf023e
fix typo
sarahelsaig Jul 12, 2022
d068663
Fix IsPowerShellCoreInstalledAsync.
sarahelsaig Jul 12, 2022
85f45a9
Fix operation in Windows PowerShell.
sarahelsaig Jul 12, 2022
1e7f925
Temporarily disable PS Analyzer unit tests.
sarahelsaig Jul 13, 2022
3b00e2a
This is probably ok.
sarahelsaig Jul 13, 2022
15c0a4d
Add `test-analysis-failure` workflow.
sarahelsaig Jul 16, 2022
307f70a
Fix id clash.
sarahelsaig Jul 16, 2022
1b10407
One should pass, one should fail.
sarahelsaig Jul 16, 2022
47a8a4c
dummy commit
sarahelsaig Jul 16, 2022
f7d1aa9
dummy commit
sarahelsaig Jul 16, 2022
01c9f23
dummy commit
sarahelsaig Jul 16, 2022
f7242a0
dummy commit
sarahelsaig Jul 16, 2022
40c869a
Add comments.
sarahelsaig Jul 16, 2022
172afcc
dummy commit
sarahelsaig Jul 16, 2022
5bbcbbb
Unusing.
sarahelsaig Jul 16, 2022
85add40
Make it wrong again.
sarahelsaig Jul 16, 2022
d2813f2
dummy commit
sarahelsaig Jul 16, 2022
c949bd2
This is not needed.
sarahelsaig Jul 16, 2022
94ddf88
Dummy commit.
sarahelsaig Jul 16, 2022
c49337e
Let's try only Windows for now.
sarahelsaig Jul 16, 2022
ed313f2
dummy commit
sarahelsaig Jul 16, 2022
90b7207
dummy commit
sarahelsaig Jul 16, 2022
0b2173d
dummy commit
sarahelsaig Jul 16, 2022
05bd378
why
sarahelsaig Jul 16, 2022
4645933
i cri everydai
sarahelsaig Jul 16, 2022
d3d1bc3
Revert "i cri everydai"
sarahelsaig Jul 16, 2022
91a1e1e
dummy commit
sarahelsaig Jul 16, 2022
467a721
dummy commit
sarahelsaig Jul 16, 2022
08060d3
Restore ubuntu for the tests.
sarahelsaig Jul 16, 2022
75207c3
Finally, fix the `build-expected-code-analysis-errors`
sarahelsaig Jul 16, 2022
dfbfaeb
Let's verify Windows is still okay after simplifying the action.
sarahelsaig Jul 16, 2022
7eb799d
Revert "Let's verify Windows is still okay after simplifying the acti…
sarahelsaig Jul 16, 2022
0f886fe
Update Readme.md
sarahelsaig Jul 20, 2022
a349d79
Update Lombiq.Analyzers.PowerShell/Invoke-Analyzer.ps1
sarahelsaig Jul 20, 2022
4cddda0
No editorconfig needed here.
sarahelsaig Jul 20, 2022
1658dc5
Explain suppression.
sarahelsaig Jul 20, 2022
d23c4e0
Add workflows to the solution.
sarahelsaig Jul 20, 2022
fba5111
Add comment about the csproj being useless.
sarahelsaig Jul 20, 2022
7727836
Fix sln links.
sarahelsaig Jul 21, 2022
8d76e2d
Fix for PS 5.
sarahelsaig Jul 21, 2022
efff6f1
Mention that suppressing a specific line or range is not supported.
sarahelsaig Jul 21, 2022
bfd735a
hmm
sarahelsaig Jul 21, 2022
ca91fb2
Replacing issue branch references
Piedone Jul 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ node_modules/
.pnpm-debug.log
.ps1-analyzer-stamp
/TestSolutions/Lombiq.Analyzers.PowerShell.*/Violate-Analyzers.ps1
/TestSolutions/*/.editorconfig
.editorconfig
7 changes: 7 additions & 0 deletions Lombiq.Analyzers.PowerShell.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers.PowerShell", "Lombiq.Analyzers.PowerShell\Lombiq.Analyzers.PowerShell.csproj", "{8802AF0F-D4CA-4ABA-8408-F4433013FF7B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Workflows", "GitHub Workflows", "{A44B4000-AF9F-47DD-A785-4778B6179090}"
ProjectSection(SolutionItems) = preProject
E:\aux_c\repositories\orchard-core\Open-Source-Orchard-Core-Extensions3\tools\Lombiq.Analyzers.PowerShell\.github\workflows\publish-nuget.yml = E:\aux_c\repositories\orchard-core\Open-Source-Orchard-Core-Extensions3\tools\Lombiq.Analyzers.PowerShell\.github\workflows\publish-nuget.yml
E:\aux_c\repositories\orchard-core\Open-Source-Orchard-Core-Extensions3\tools\Lombiq.Analyzers.PowerShell\.github\workflows\test-analysis-failure.yml = E:\aux_c\repositories\orchard-core\Open-Source-Orchard-Core-Extensions3\tools\Lombiq.Analyzers.PowerShell\.github\workflows\test-analysis-failure.yml
E:\aux_c\repositories\orchard-core\Open-Source-Orchard-Core-Extensions3\tools\Lombiq.Analyzers.PowerShell\.github\workflows\verify-submodule-pull-request.yml = E:\aux_c\repositories\orchard-core\Open-Source-Orchard-Core-Extensions3\tools\Lombiq.Analyzers.PowerShell\.github\workflows\verify-submodule-pull-request.yml
Piedone marked this conversation as resolved.
Show resolved Hide resolved
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Analyzers.PowerShell/Invoke-Analyzer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if ((Get-InstalledModule PSScriptAnalyzer -ErrorAction SilentlyContinue).Version
{
try
{
# Attempt to install it automatically. This will fail on Windows Powershell becuase you have to be admin.
# Attempt to install it automatically. This will fail on Windows PowerShell because you have to be admin.
Install-Module -Name PSScriptAnalyzer -Force -RequiredVersion $installVersion
}
catch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- This csproj file is only needed for NuGet package creation and to make the files visible in IDE. It doesn't
contain anything that needs to be built. -->

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*</DefaultItemExcludes>
Expand Down
8 changes: 7 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## About

PowerShell static code analysis via [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) and [Lombiq's recommended configuration for it](Lombiq.Analyzers.PowerShell/PSScriptAnalyzerSettings.psd1).
PowerShell static code analysis via [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) and [Lombiq's recommended configuration for it](Lombiq.Analyzers.PowerShell/PSScriptAnalyzerSettings.psd1).

Do you want to quickly try out this project and see it in action? Check it out in our [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions) full Orchard Core solution and also see our other useful Orchard Core-related open-source projects!

Expand Down Expand Up @@ -55,6 +55,8 @@ If this project is included via a submodule, edit the _csproj_ file of your prim
<Import Project="path\to\Lombiq.Analyzers.PowerShell\Lombiq.Analyzers.PowerShell.targets" />
```

You don't need to `<ProjectReference>` _Lombiq.Analyzers.PowerShell.csproj_.

If you include the project as a NuGet package, it will work as-is.

Additionally, you can set these properties in the importing project's `<PropertyGroup>`:
Expand All @@ -68,6 +70,10 @@ Live analysis is outside of the scope of this project, however you can use the V
2. Go to Settings and paste `powershell.scriptAnalysis.settingsPath` into the search bar.
3. Set it to the path of the _PSScriptAnalyzerSettings.psd1_ file to use our settings.

### Suppressing PSScriptAnalyzer rules

Occasionally there is good reason to ignore an analyzer warning. In this case add the `[Diagnostics.CodeAnalysis.SuppressMessage('Rule Code', Justification = 'Explain reason.')]` attribute to the cmdlet's `param()`. For more information, see the module's [documentation](https://docs.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/using-scriptanalyzer?view=ps-modules#suppressing-rules).
Piedone marked this conversation as resolved.
Show resolved Hide resolved

## Contributing and support

Bug reports, feature requests, comments, questions, code contributions, and love letters are warmly welcome, please do so via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so.
Expand Down