Skip to content

Fix PSScriptAnalyzer warnings and errors #3791

Closed

Description

We should be PSScriptAnalyzer clean and any new PRs should pass PSScriptAnalyzer

PS> $e = Get-ChildItem -Recurse -Include *.ps1,*.psm1 | ? { $_.fullname -notmatch "\\bin\\" } | % { Invoke-ScriptAnalyzer -Path $_ }
PS> $e | Group-Object severity

Count Name                      Group
----- ----                      -----
 1528 Warning                   {Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord, Microsoft.Win...
   20 Error                     {Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord, Microsoft.Win...
  129 Information               {Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord, Microsoft.Win...

Activity

  1. added
    WG-Quality-Testissues in a test or in test infrastructure
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    on May 16, 2017
  2. added this to the milestone on May 16, 2017
  3. mi-hol commented on Mar 1, 2018

    @mi-hol

    $e | select-Object ScriptName | Group-Object ScriptName |format-table -autosize
    Affected files identified below are the ones to be fixed, correct?
    Count Name
    '----- ----
    4 Microsoft.PowerShell.Archive.psm1
    1 Microsoft.PowerShell.Utility.psm1
    4 MSFT_PackageManagement.psm1
    3 MSFT_PackageManagementSource.psm1
    1 PackageManagementDscUtilities.psm1
    9 PackageProviderFunctions.psm1
    115 PSModule.psm1
    74 PSDesiredStateConfiguration.psm1
    14 PSDiagnostics.psm1
    4 Install-PowerShellRemoting.ps1
    3 RegisterManifest.ps1

    I've tried to locate the source file for 'Microsoft.PowerShell.Utility.psm1' in this repository but didn't succeed. Any hint?

  4. SteveL-MSFT commented on Mar 1, 2018

    @SteveL-MSFT
    MemberAuthor

    Running off latest master, I got 303 files:

    $e | select scriptname -unique

  5. SteveL-MSFT commented on Mar 1, 2018

    @SteveL-MSFT
    MemberAuthor

    mi-hol if you want to help out, I would suggest not fixing them all at once (which would make the PR review more difficult), but perhaps each folder can be a separate PR. Thanks!

  6. mi-hol commented on Mar 2, 2018

    @mi-hol

    Steve Lee (@SteveL-MSFT) sure thats the right approach and reason why I've tried to locate the source file for 'Microsoft.PowerShell.Utility.psm1' in this repository but didn't succeed.
    What file would you suggest that I'd try first?

  7. SteveL-MSFT commented on Mar 2, 2018

    @SteveL-MSFT
    MemberAuthor

    Perhaps start with all the psm1 files

  8. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  9. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  10. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  11. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Code Cleanupthe issue is for cleaning up the code with no impact on functionalityResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Quality-Testissues in a test or in test infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions