Skip to content

Profile example in Readme.md no longer works #475

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

Closed
rkeithhill opened this issue Mar 23, 2016 · 1 comment
Closed

Profile example in Readme.md no longer works #475

rkeithhill opened this issue Mar 23, 2016 · 1 comment
Assignees

Comments

@rkeithhill
Copy link
Contributor

This example doesn't work because -Profile now expects a path to a profile file:

$myProfile = @{
    Severity='Warning'
    IncludeRules=@('PSAvoidUsingCmdletAliases',
                    'PSAvoidUsingPositionalParameters',
                    'PSAvoidUsingInternalURLs'
                    'PSAvoidUninitializedVariable')
    ExcludeRules=@('PSAvoidUsingCmdletAliases'
                   'PSAvoidUninitializedVariable')
}

Invoke-ScriptAnalyzer -path MyScript.ps1 -Profile $myProfile

BTW it would be nice if the team could offer a recommend standard name for these files. Or at least use it in the revised sample above. Perhaps something like PSScriptAnalyzerProfile.psd1 or maybe just ScriptAnalyzerProfile.psd1? I like using the PSD1 extension so that I get syntax coloring in my PowerShell editor (VSCode) when I'm editing this file.

Here's an updated sample:

@'
@{
    Severity='Warning'
    IncludeRules=@('PSAvoidUsingCmdletAliases',
                    'PSAvoidUsingPositionalParameters',
                    'PSAvoidUsingInternalURLs'
                    'PSAvoidUninitializedVariable')
    ExcludeRules=@('PSAvoidUsingCmdletAliases'
                   'PSAvoidUninitializedVariable')
}
'@ > ScriptAnalyzerProfile.psd1

Invoke-ScriptAnalyzer -path MyScript.ps1 -Profile ScriptAnalyzerProfile.psd1

Update: I notice that 1.4.0 will not complain if I pass a hashtable directly to -Profile but it also does not seem to honor the settings in the hashtable. Also the fact that the -Profile parameter is of type [string] leads me to believe this support just a path and not a hashtable. Perhaps the parameter should be renamed -ProfilePath or -SettingsPath (with an alias of 'Profile' to avoid compat breaks)?

rkeithhill added a commit to rkeithhill/PSScriptAnalyzer that referenced this issue Mar 23, 2016
@daviwil
Copy link
Contributor

daviwil commented Mar 23, 2016

We're discussing the usage of Script Analyzer profile files over on the vscode-powershell repo: PowerShell/vscode-powershell#122

rkeithhill added a commit to rkeithhill/PSScriptAnalyzer that referenced this issue Mar 23, 2016
This also demonstrates some usage scenarios that would be a bit more common.
@kapilmb kapilmb self-assigned this Apr 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants