Title: Rule PSUseDeclaredVarsMoreThanAssignments generates false positives (warnings) where it should not · Issue #201 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: Rule PSUseDeclaredVarsMoreThanAssignments generates false positives (warnings) where it should not · Issue #201 · PowerShell/PSScriptAnalyzer
X Title: Rule PSUseDeclaredVarsMoreThanAssignments generates false positives (warnings) where it should not · Issue #201 · PowerShell/PSScriptAnalyzer
Description: Problem #1: It is common in psm1 files to define variables that are used by functions in the rest of the module. These module-scope variables are often initialized and not used in the psm1 file itself. Yet running Invoke-ScriptAnalyzer a...
Open Graph Description: Problem #1: It is common in psm1 files to define variables that are used by functions in the rest of the module. These module-scope variables are often initialized and not used in the psm1 file its...
X Description: Problem #1: It is common in psm1 files to define variables that are used by functions in the rest of the module. These module-scope variables are often initialized and not used in the psm1 file its...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/201
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rule PSUseDeclaredVarsMoreThanAssignments generates false positives (warnings) where it should not","articleBody":"Problem #1:\nIt is common in psm1 files to define variables that are used by functions in the rest of the module. These module-scope variables are often initialized and not used in the psm1 file itself. Yet running Invoke-ScriptAnalyzer against a psm1 file that defines these variables and properly initialized them causes warnings to be generated using this rule.\n\nSolution #1:\nOnce Invoke-ScriptAnalyzer supports invocation against modules (as proposed in #199), this rule should check more broadly to see if variables that are declared and initialized in a script module (psm1) file are used in other files in the module. These variables that are in \"script\" scope can be found by looking for $script:variableName or by looking for references to Get-/Set-/Remove-Variable -Scope Script -Name variableName.\n\nProblem #2:\nThis rule generates a warning against a function that sets a built-in variable using the script scope. I have the following line in one of my functions:\n$Script:PSDefaultParameterValues['Get-DoPxWebRequestHeader:AccessToken'] = $AccessToken\n\nSolution #2:\nThat line is perfectly valid, and it is not initializing a variable that is never used because it is a built-in variable. This rule needs to ignore built-in variables, whether they are scoped (script/global, or using numeric scopes with Get-/Set-Variable in the -Scope parameter) or not.\n","author":{"url":"https://github.com/KirkMunro","@type":"Person","name":"KirkMunro"},"datePublished":"2015-05-22T20:14:51Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/201"}
| 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:efd72198-aba7-1216-68bc-98cc99b6062c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E184:1861F0:C3E884:10DA7EF:6AFD428D |
| html-safe-nonce | dc0abb5ff8a6ddae05b686fcc95ac6e8e30dc3caff415e9fbfc0e34a59a873bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTg0OjE4NjFGMDpDM0U4ODQ6MTBEQTdFRjo2QUZENDI4RCIsInZpc2l0b3JfaWQiOiIyMTk4Mzc3NDEwMjI5NzgxMTM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3fe574433dde00028cc92a46384089b34a271914740af99f507c831e8a4b5c45 |
| hovercard-subject-tag | issue:79593126 |
| 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/201/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a15472cdba5c196d5b5f57184d175257a9ad7f422bf4c39462ad215a49447c10/PowerShell/PSScriptAnalyzer/issues/201 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a15472cdba5c196d5b5f57184d175257a9ad7f422bf4c39462ad215a49447c10/PowerShell/PSScriptAnalyzer/issues/201 |
| og:image:alt | Problem #1: It is common in psm1 files to define variables that are used by functions in the rest of the module. These module-scope variables are often initialized and not used in the psm1 file its... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | KirkMunro |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| 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 | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width