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

Updates to Examples PSSA settings file to include more rule config #1312

Merged
Merged
Changes from 1 commit
Commits
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
49 changes: 46 additions & 3 deletions examples/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# The PowerShell Script Analyzer will generate a warning
# diagnostic record for this file due to a bug -
# https://github.com/PowerShell/PSScriptAnalyzer/issues/472
# For more information on PSScriptAnalyzer settings see:
# https://github.com/PowerShell/PSScriptAnalyzer/blob/master/README.md#settings-support-in-scriptanalyzer
Copy link
Contributor

@bergmeister bergmeister May 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also linking to the shipped settings files (as real examples) could be useful: https://github.com/PowerShell/PSScriptAnalyzer/tree/master/Engine/Settings

@{
# Only diagnostic records of the specified severity will be generated.
# Uncomment the following line if you only want Errors and Warnings but
Expand All @@ -25,4 +24,48 @@
# Note: if a rule is in both IncludeRules and ExcludeRules, the rule
# will be excluded.
#ExcludeRules = @('PSAvoidUsingWriteHost')

# You can use rule configuration to configure rules that support it:
#Rules = @{
# PSAlignAssignmentStatement = @{
# Enable = $true
# CheckHashtable = $true
# }
# PSAvoidUsingCmdletAliases = @{
# Whitelist = @("cd")
# }
# PSPlaceCloseBrace = @{
# Enable = $true
# NoEmptyLineBefore = $false
# IgnoreOneLineBlock = $true
# NewLineAfter = $true
# }
# PSPlaceOpenBrace = @{
# Enable = $true
# OnSameLine = $true
# NewLineAfter = $true
# IgnoreOneLineBlock = $true
# }
# PSProvideCommentHelp = @{
# Enable = $true
# ExportedOnly = $false
# BlockComment = $true
# VSCodeSnippetCorrection = $false
# Placement = "before"
# }
# PSUseCompatibleCmdlets = @{
# compatibility = @("core-6.0.0-alpha-windows", "core-6.0.0-alpha-linux")
Copy link
Contributor

@bergmeister bergmeister May 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to merge this PR before the release next week, which will delete those files and replace it with newer ones. Therefore I would remove this example, you do not need to document PSSA details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd much prefer a link to a list of configurable PSSA rules but I didn't see one. I spent ~10 minutes going through every single rule doc, looking for the ones that are configurable. I think it would be nice if PSSA had a list of configurable rules that could be linked to. :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get-ScriptAnalyzer gives you all the rules and one has to look at each rule doc for configuration. The plan is to include one settings file in the PSSA repo itself with all rules and options being present. I had the same problem when doing it the first time for me a few months ago and had only the rule docs and example files. Since I didn't write the tool, I can also only use as much as currently is there. I learn more about it as I read the code and improve docs as I go along.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that somewhere in this README it would be helpful to have a list of the configurable rules.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have deleted this ReadMe already in the development branch because it got too much out of date and there is a lot of duplicated and outdated information on the repo. Why do you want to know whether a rule is configurable? The idea would be that one takes the monolithic example file with all rules and configuration examples and then one deletes the rules that one is not interested in and adapt the configuration of the remaining rules.
There is an outstanding issue to get all configurable rules using Get-ScriptAnalyzer and I remember giving it a quick try in an attempted PR and there were various problems, hence why I left the issue for the moment: PowerShell/PSScriptAnalyzer#823

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's too bad. I just submitted a PR to fix the broken links and add a column for Configurable. Because I'm too lazy and don't have enough time to read through all the docs. If a rule isn't working for me, I'll just disable it. OTOH if I saw that the rule was configurable it wouldn't take me long to make it work for me, then I'd leave it enabled.

# }
# PSUseConsistentIndentation = @{
# Enable = $true
# IndentationSize = 4
# }
# PSUseConsistentWhitespace = @{
# Enable = $true
# CheckOpenBrace = $true
# CheckOpenParen = $true
# CheckOperator = $true
# CheckSeparator = $true
# }
# }
}