Title: PSUseDeclaredVarsMoreThanAssignment not correctly handling array adds · Issue #699 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: PSUseDeclaredVarsMoreThanAssignment not correctly handling array adds · Issue #699 · PowerShell/PSScriptAnalyzer
X Title: PSUseDeclaredVarsMoreThanAssignment not correctly handling array adds · Issue #699 · PowerShell/PSScriptAnalyzer
Description: Given the following code $msg = @() @("a", "b") | ForEach-Object { $msg += $_ } Write-Information $msg -InformationAction Continue I get the following warning: The variable 'msg' is assigned but never used. (line 2) I realize that this g...
Open Graph Description: Given the following code $msg = @() @("a", "b") | ForEach-Object { $msg += $_ } Write-Information $msg -InformationAction Continue I get the following warning: The variable 'msg' is assigned but ne...
X Description: Given the following code $msg = @() @("a", "b") | ForEach-Object { $msg += $_ } Write-Information $msg -InformationAction Continue I get the following warning: The variable '...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/699
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PSUseDeclaredVarsMoreThanAssignment not correctly handling array adds","articleBody":"Given the following code\r\n\r\n```\r\n$msg = @()\r\n@(\"a\", \"b\") | ForEach-Object { $msg += $_ }\r\nWrite-Information $msg -InformationAction Continue\r\n```\r\nI get the following warning:\r\n* The variable 'msg' is assigned but never used. (line 2)\r\n\r\nI realize that this generates a new array each time, but it is both being assigned to and read, so this appears to be a false positive.\r\n\r\nAnother similar scenario:\r\n\r\n```\r\n$params = (@{\"a\" = 1; \"b\" = 2}).GetEnumerator() |\r\n ForEach-Object { $m = @{} } { $m[$_.Name] = $_.Value } { $m } # foreach begin{} process{} end{}\r\n$params\r\n```\r\n* The variable 'm' is assigned but never used. (line 2)","author":{"url":"https://github.com/HowardWolosky","@type":"Person","name":"HowardWolosky"},"datePublished":"2017-01-31T23:18:43Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/699"}
| 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:718a7dc6-4974-ba8e-49ff-7d21ea3c9df7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC90:2768A7:19156B:2135BE:6AFD0038 |
| html-safe-nonce | d771597b46888f2825bf7d5700636bf0126d2156349ddf3d5687234dfb670d7b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzkwOjI3NjhBNzoxOTE1NkI6MjEzNUJFOjZBRkQwMDM4IiwidmlzaXRvcl9pZCI6IjM2MTM1NzI1OTYwMDU0MDQ3MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6d40394fe99310efd00c20c442c52e0dd63fa33b416e379c9a2a54e8c25811ca |
| hovercard-subject-tag | issue:204453306 |
| 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/699/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1dfd9710a237912b9078ce299b7c51fcb8a69678a550e2f1b6fe2d46658b309f/PowerShell/PSScriptAnalyzer/issues/699 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1dfd9710a237912b9078ce299b7c51fcb8a69678a550e2f1b6fe2d46658b309f/PowerShell/PSScriptAnalyzer/issues/699 |
| og:image:alt | Given the following code $msg = @() @("a", "b") | ForEach-Object { $msg += $_ } Write-Information $msg -InformationAction Continue I get the following warning: The variable 'msg' is assigned but ne... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | HowardWolosky |
| hostname | github.com |
| expected-hostname | github.com |
| None | cfabad6ee26d2b84c7afef4ae0cc71b8b692fb9d66f9f15997652ef991bfd3f4 |
| 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 | 35f85b78676038389558a41adf8d76e474592ede |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width