-
Notifications
You must be signed in to change notification settings - Fork 1
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 further analyzer rules for better code styling control and more (OSOE-501) #16
Comments
When if ($Env:RUNNER_OS -eq "Windows")
{
sqlcmd -b -S .\SQLEXPRESS -Q "SELECT @@SERVERNAME as ServerName" 2>&1>$null
}
else
{
sqlcmd -b -U sa -P 'Password1!' -Q "SELECT @@SERVERNAME as ServerName" 2>&1>$null
} VSCode autoformatting changes this to the following, making the warnings go away, but I don't think this is correct: if ($Env:RUNNER_OS -eq "Windows")
{
sqlcmd -b -S .\SQLEXPRESS -Q "SELECT @@SERVERNAME as ServerName" >$null
}
else
{
sqlcmd -b -U sa -P 'Password1!' -Q "SELECT @@SERVERNAME as ServerName" >$null
} @DAud-IcI do you know if we can just update this to save into a variable or something similar to instead of the "exotic" syntax? |
Also, when Update-VisualStudioSolutionNuGetPackages -Path (Get-Location).Path -ProjectNameFilter "Lombiq.*" -PackageNameFilter "Lombiq.*"
Any ideas? GHA execution is fine though. |
…meter to false See: #16 (comment)
mfw someone calls the stream redirection syntax that has been common in pretty much all shells since the dawn of time "exotic".
It appears the script throws a PowerShell syntax error, it can't even be caught using try-catch. The reason it "works" in GHA is because it doesn't produce the error GHA expects. So I'm afraid the '@{ Rules = @{ PSUseCorrectCasing = @{ Enable = $true } } }' > rules.psd1
Invoke-ScriptAnalyzer -Settings rules.psd1 -ScriptDefinition 'Update-VisualStudioSolutionNuGetPackages' |
Ha! :D
So, the reformatted version doesn't break it and
Thanks! The weird thing is that the original code doesn't violate PSUseCorrectCasing either and that analyzer works just fine otherwise. |
I don't know what the heck is going on with the |
The second part of the commandlet name is currently 33 characters long - maybe 32 is a magical number here?! The name is quite long, admittedly. Why does VisualStudio have to be part of it, anyway? |
I noticed that too, but we have cmdlets with longer names, e.g., |
I factored out 3 analyzers to separate issue (see them marked with ✅ in the description), so this is done. |
A very wise decision, let me tell you! |
Check this out! PowerShell/PSScriptAnalyzer#1881 (comment)
|
Review https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/readme and out of the ones that aren't enabled by default, select the appropriate ones. Repositories to check: OSOCE, Infrastructure Scripts, Utility Scripts.
Complete list:
powerShell.codeFormatting.useConstantStrings
is enabled. We're currently only surfacing Warnings and Errors (but not Information entries). This rule has Information severity, but the docs is outdated on that, so I created an issue and PR: Documentation is outdated on the AvoidUsingDoubleQuotesForConstantString rule's Severity and Configurability MicrosoftDocs/PowerShell-Docs-Modules#128We can lower the threshold (I'd actually rather move it to the settings file from Invoke-Analyzers.ps1) to Information and then disable the rules that we don't care about but enabled by default (there are only 2 such possible rules).
Not yet enabled because of Enabling PSUseCorrectCasing causes error while processing code that doesn't violate it PowerShell/PSScriptAnalyzer#1881. Moved to (blocked) Enable PSUseCorrectCasing analyzer rule (OSOE-539) #22.Jira issue
The text was updated successfully, but these errors were encountered: