Title: Custom Rule Consistency · Issue #1237 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: Custom Rule Consistency · Issue #1237 · PowerShell/PSScriptAnalyzer
X Title: Custom Rule Consistency · Issue #1237 · PowerShell/PSScriptAnalyzer
Description: It's frustrating that there's no automatic relationship between the rules in the output of Get-ScriptAnalzyerRule -CustomRulePath and Invoke-ScriptAnalyzer ... Specifically, the -ExcludeRule of Invoke-ScriptAnalyzer has to match the cust...
Open Graph Description: It's frustrating that there's no automatic relationship between the rules in the output of Get-ScriptAnalzyerRule -CustomRulePath and Invoke-ScriptAnalyzer ... Specifically, the -ExcludeRule of Inv...
X Description: It's frustrating that there's no automatic relationship between the rules in the output of Get-ScriptAnalzyerRule -CustomRulePath and Invoke-ScriptAnalyzer ... Specifically, the -ExcludeRul...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Custom Rule Consistency","articleBody":"It's frustrating that there's no _automatic_ relationship between the rules in the output of `Get-ScriptAnalzyerRule -CustomRulePath` and `Invoke-ScriptAnalyzer ...`\r\n\r\nSpecifically, the `-ExcludeRule` of `Invoke-ScriptAnalyzer` has to match the custom rule function name (without the module on the front).\r\n\r\nBut the name you have to put in `SuppressMessageAttribute` has to match the `RuleName` which is _set_ on the output of the function, so if you use `RuleName = $PSCmdlet.MyInvocation.InvocationName` then you **must** use the module-qualified rule name, and if you use `RuleName = $PSCmdlet.MyInvocation.MyCommand.Name` then you **must not** ...\r\n\r\nBut the coup-de-grace, if you `Invoke-ScriptAnalyzer` with `-IncludeDefaultRules` then you can't use names in SuppressMessageAttribute which are not module-qualified except for the default rules.\r\n\r\n## There is just **no way** to make it work\r\n\r\nThere's no combination where I can consistently use the same name for `-ExcludeRule` and `SuppressMessageAttribute`\r\n\r\nThis is a problem. It makes sense for these to be module-qualified, and calculated by PSScriptAnalyzer, not the rule author. I think ScriptAnalyzer should **require** the rule function names to use the `Measure` verb, and then use the **noun** as the rule name -- and ignore/overwrite the output value.\r\n\r\nThat way you can guarantee that the rule name will always be what you expect it to be. Then, the `-ExcludeRule` parameter and `Get-ScriptAnalyzerRule` need to be updated to return the same value too.\r\n\r\n### Severity is wrong too\r\n\r\nCurrently all Custom rules are shown as \"Warning\" severity in the output of `Get-ScriptAnalyzerRule` but (can) have different severity when the rule is actually triggered (actually, they can assign a severity based on logic in the rule).\r\n\r\nWe should add an **attribute** to allow authors to specify the (default?) severity of the rule that would be reported by `Get-ScriptAnalyzerRule` (and we should use that severity by default, allowing rule authors to skip setting the RuleName, Severity, and RuleSuppressionId and have them correctly populated in the output).","author":{"url":"https://github.com/Jaykul","@type":"Person","name":"Jaykul"},"datePublished":"2019-05-08T22:15:34Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1237"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:58955793-d4d1-6fc5-b149-51512582133f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BAE:17B0B7:3FBBF1:541037:6AFCE999 |
| html-safe-nonce | 581dc1b6807895d086673b8f32d2112fb76a7d1e750ee00c1723a05fd575440e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkFFOjE3QjBCNzozRkJCRjE6NTQxMDM3OjZBRkNFOTk5IiwidmlzaXRvcl9pZCI6IjM4ODUxNjM4MTM1ODU4NzMzMDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ddbe7a2265e96993f7f7f3124c76d439e625332e66c59cb84d18c4369626e804 |
| hovercard-subject-tag | issue:441955023 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8b40c74dd51bda943b9982eae153eebc9a20980f5ca408d8a3c3a40d26e5303a/PowerShell/PSScriptAnalyzer/issues/1237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8b40c74dd51bda943b9982eae153eebc9a20980f5ca408d8a3c3a40d26e5303a/PowerShell/PSScriptAnalyzer/issues/1237 |
| og:image:alt | It's frustrating that there's no automatic relationship between the rules in the output of Get-ScriptAnalzyerRule -CustomRulePath and Invoke-ScriptAnalyzer ... Specifically, the -ExcludeRule of Inv... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jaykul |
| hostname | github.com |
| expected-hostname | github.com |
| None | 99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ecfd63ca125ec74b42f74eeb158b3fa081c8c497 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width