René's URL Explorer Experiment


Title: Cannot Suppress Messages About a Specific Automatic Variable · Issue #1589 · PowerShell/PSScriptAnalyzer · GitHub

Open Graph Title: Cannot Suppress Messages About a Specific Automatic Variable · Issue #1589 · PowerShell/PSScriptAnalyzer

X Title: Cannot Suppress Messages About a Specific Automatic Variable · Issue #1589 · PowerShell/PSScriptAnalyzer

Description: Setting the CheckID of a SuppressMessageAttribute decoration to '_' fails to suppress the specified message about the '_' automatic variable. Specifically, this fails: [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignment...

Open Graph Description: Setting the CheckID of a SuppressMessageAttribute decoration to '_' fails to suppress the specified message about the '_' automatic variable. Specifically, this fails: [Diagnostics.CodeAnalysis.Sup...

X Description: Setting the CheckID of a SuppressMessageAttribute decoration to '_' fails to suppress the specified message about the '_' automatic variable. Specifically, this fails: [Diagnostics....

Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1589

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot Suppress Messages About a Specific Automatic Variable","articleBody":"Setting the CheckID of a `SuppressMessageAttribute` decoration to '\\_' fails to suppress the specified message about the '\\_' automatic variable.\r\n\r\nSpecifically, this fails:\r\n`[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '_', Justification='Assignment is by design.')]`\r\nWhile this works as expected:\r\n`[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification='Assignment is by design.')]`\r\n\r\nSteps to reproduce\r\n------------------\r\nRun `Invoke-ScriptAnalyzer` against the following PowerShell script.\r\n```PowerShell\r\nfunction Import-StringData {\r\n[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '_', Justification='Assignment is by design.')]\r\n[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'newEntryTemplate', Justification='The subsequent use of newEntryTemplate is not detected by PSScriptAnalyzer.')]\r\nParam([string]$stringToParse)\r\n#region Prepare CrossRef Table\r\n    [System.Data.DataTable]$dt = New-Object System.Data.DataTable\r\n    $dt.Columns.Add(\"measCode\", [string]) | Out-Null\r\n    $dt.Columns.Add(\"measBasis\", [string]) | Out-Null\r\n    $dt.Rows.Add(@(\"BZ\",\"MMBtu\")) | Out-Null\r\n    $dt.Rows.Add(@(\"G8\",\"Gigacalories\")) | Out-Null\r\n    $dt.Rows.Add(@(\"GV\",\"Gigajoules\")) | Out-Null\r\n    $dt.Rows.Add(@(\"TZ\",\"MCF\")) | Out-Null\r\n    $dt.AcceptChanges()\r\n#endregion Prepare CrossRef Table\r\n\r\n    $stringToParse | Select-Object -First 7 | ForEach-Object -Begin {$newEntryTemplate = \"`r`n{0}={1}\"} -Process {\r\n        $match = ($_ | Select-String \"Meas Basis Desc[:] (.*)\" -List).Matches\r\n        if($null -ne $match){$_ += $newEntryTemplate -f \"measCode\", $dt.Select(\"measBasis='$($match.Groups[1].Value)'\").measCode}\r\n        $_ -replace \": \", \"=\"} | ConvertFrom-StringData\r\n}\r\n\r\n$stringToParse = @\"\r\nPosting Date: 2020-09-17\r\nPosting Time: 22:05:44    \r\nEffective Gas Day: 2020-09-18\r\nEffective Gas Time: 9:00:00 am  \r\nMeas Basis Desc: MMBtu\r\n\"@\r\n\r\nImport-StringData $stringToParse\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n`Invoke-ScriptAnalyzer` should find 0 rule violations.\r\n\r\nThe `PSAvoidAssignmentToAutomaticVariable` warning about the '\\_' variable on line 18 should be suppressed as per the targeted `SuppressMessageAttribute` decoration on line 2.  \r\n\r\nActual behavior\r\n---------------\r\nThe `SuppressMessageAttribute` decoration on line 2 has no effect and `Invoke-ScriptAnalyzer` outputs the following:\r\n>Invoke-ScriptAnalyzer: Suppression Message Attribute error at line 2 in Test PSScriptAnalyzer.ps1 : Cannot find any DiagnosticRecord with the Rule Suppression ID \\_.\r\n>\r\n>RuleName | Severity | ScriptName | Line | Message\r\n>-------- | -------- | ---------- | ---- | -------\r\n>PSAvoidAssignmentToAutomaticVariable | Warning | Test Suppression.ps1 |18 | The Variable '\\_' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.\r\n>\r\n>1 rule violation found.    Severity distribution:  Error = 0, Warning = 1, Information = 0\r\n\r\nEnvironment data\r\n----------------\r\n```PowerShell\r\n> $PSVersionTable\r\nName                           Value\r\n----                           -----\r\nPSVersion                      7.0.3\r\nPSEdition                      Core\r\nGitCommitId                    7.0.3\r\nOS                             Microsoft Windows 10.0.18363\r\nPlatform                       Win32NT\r\nPSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion      2.3\r\nSerializationVersion           1.1.0.1\r\nWSManStackVersion              3.0\r\n\r\n> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }\r\n1.19.1\r\n```\r\n","author":{"url":"https://github.com/marshallwp","@type":"Person","name":"marshallwp"},"datePublished":"2020-09-18T16:28:06Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1589"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3eb2f008-9ba2-83bd-76a0-f0632b604c2a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9C58:2C8B07:8AF580:C08A64:6AFD2FA5
html-safe-nonce16dfaeb6804218aa922a506323d29ab496db1da90a0fd961e3b4f67a2c7c5368
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzU4OjJDOEIwNzo4QUY1ODA6QzA4QTY0OjZBRkQyRkE1IiwidmlzaXRvcl9pZCI6IjczMzQ0MDYxMjcyMTMxNjI0MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac54fe93fedda4fc152b7e6901e7339132d4f73e3c8661fd9e30b5a252ec7e2e81
hovercard-subject-tagissue:704506847
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1589/issue_layout
twitter:imagehttps://opengraph.githubassets.com/08de04fa1303e56899e5b936cd80ffa1e747373f072ffef88a686e2d4e4d0eb0/PowerShell/PSScriptAnalyzer/issues/1589
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/08de04fa1303e56899e5b936cd80ffa1e747373f072ffef88a686e2d4e4d0eb0/PowerShell/PSScriptAnalyzer/issues/1589
og:image:altSetting the CheckID of a SuppressMessageAttribute decoration to '_' fails to suppress the specified message about the '_' automatic variable. Specifically, this fails: [Diagnostics.CodeAnalysis.Sup...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemarshallwp
hostnamegithub.com
expected-hostnamegithub.com
None065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id33149177
octolytics-dimension-repository_nwoPowerShell/PSScriptAnalyzer
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33149177
octolytics-dimension-repository_network_root_nwoPowerShell/PSScriptAnalyzer
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release941021edf0c2ec58298f4a2c8f27ae507d129c92
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PSScriptAnalyzer/issues/1589#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F1589
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F1589
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPSScriptAnalyzer
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/1589
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/1589
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/1589
PowerShellhttps://github.com/PowerShell
PSScriptAnalyzerhttps://github.com/PowerShell/PSScriptAnalyzer
Codehttps://github.com/PowerShell/PSScriptAnalyzer
Issues407 (407)https://github.com/PowerShell/PSScriptAnalyzer/issues
Pull requests34 (34)https://github.com/PowerShell/PSScriptAnalyzer/pulls
Discussionshttps://github.com/PowerShell/PSScriptAnalyzer/discussions
Actionshttps://github.com/PowerShell/PSScriptAnalyzer/actions
Projectshttps://github.com/PowerShell/PSScriptAnalyzer/projects
Wikihttps://github.com/PowerShell/PSScriptAnalyzer/wiki
Security and qualityhttps://github.com/PowerShell/PSScriptAnalyzer/security
Insightshttps://github.com/PowerShell/PSScriptAnalyzer/insights
https://github.com/PowerShell/PSScriptAnalyzer
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1589
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1589
#1896https://github.com/PowerShell/PSScriptAnalyzer/pull/1896
Cannot Suppress Messages About a Specific Automatic Variablehttps://github.com/PowerShell/PSScriptAnalyzer/issues/1589#top
#1896https://github.com/PowerShell/PSScriptAnalyzer/pull/1896
Area - Ruleshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Rules%22
Issue - Enhancementhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20Enhancement%22
Up-for-Grabshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Up-for-Grabs%22
https://github.com/marshallwp
William Marshall (marshallwp)https://github.com/marshallwp
on Sep 18, 2020https://github.com/PowerShell/PSScriptAnalyzer/issues/1589#issue-704506847
Sydney Smith (SydneyhSmith)https://github.com/SydneyhSmith
Area - Configurationhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Configuration%22
Issue - Enhancementhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20Enhancement%22
on Sep 22, 2020https://github.com/PowerShell/PSScriptAnalyzer/issues/1589#event-3794448734
https://github.com/SydneyhSmith
Sydney Smith (SydneyhSmith)https://github.com/SydneyhSmith
on Sep 22, 2020https://github.com/PowerShell/PSScriptAnalyzer/issues/1589#issuecomment-696875484
Sydney Smith (SydneyhSmith)https://github.com/SydneyhSmith
Area - Ruleshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Rules%22
Up-for-Grabshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Up-for-Grabs%22
Area - Configurationhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Configuration%22
on Sep 22, 2020https://github.com/PowerShell/PSScriptAnalyzer/issues/1589#event-3794460145
Frode Flaten (fflaten)https://github.com/fflaten
on Feb 27, 2023https://github.com/PowerShell/PSScriptAnalyzer/issues/1589#event-8619153789
add ruleId to PSAvoidAssignmentToAutomaticVariablehttps://github.com/fflaten/PSScriptAnalyzer/commit/31926f0e569d5f78f2e355d6546e260b4b9ce326
https://docs.github.com/articles/closing-issues-via-commit-messages
31926f0https://github.com/fflaten/PSScriptAnalyzer/commit/31926f0e569d5f78f2e355d6546e260b4b9ce326
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
completedhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#1896https://github.com/PowerShell/PSScriptAnalyzer/pull/1896
on Sep 17, 2023https://github.com/PowerShell/PSScriptAnalyzer/issues/1589#event-10391812071
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Sep 17, 2023https://github.com/PowerShell/PSScriptAnalyzer/issues/1589#event-10391812087
Enable suppression of PSAvoidAssignmentToAutomaticVariable for specif…https://github.com/PowerShell/PSScriptAnalyzer/commit/40be5932808940f8cd89f8d8be7c35772fcdb5d5
https://docs.github.com/articles/closing-issues-via-commit-messages
40be593https://github.com/PowerShell/PSScriptAnalyzer/commit/40be5932808940f8cd89f8d8be7c35772fcdb5d5
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1589
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1589
Area - Ruleshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Rules%22
Issue - Enhancementhttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20Enhancement%22
Up-for-Grabshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Up-for-Grabs%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.