PowerShell / PowerShell/PSScriptAnalyzer

Unable to suppress PSAvoidLongLines warning in a method

Đang mở
#1,591 12 bình luận 0 reaction 1 người được giao Xem trên GitHub

@thomasrayner đang làm issue này rồi.

Từ ngày 25/10/2020.

Area - Rules Issue - Bug Up-for-Grabs
Ngôn ngữ chính
C#
Star
2.2k
Fork
414
Merge trung bình
13 giờ 1 phút
Pull request đã merge (30 ngày)
2

Mô tả

I'm unable to suppress the PSAvoidLongLines warning in a method inside a class.

Steps to reproduce

Run Invoke-ScriptAnalyzer -Path . -Recurse while the following PSScriptAnalyzerSettings.psd1 file is present in the folder:

@{
  Severity     = @('Error', 'Warning', 'Information')
  ExcludeRules = @('PSUseBOMForUnicodeEncodedFile',
    'PSAvoidUsingConvertToSecureStringWithPlainText',
    'PSAvoidUsingPlainTextForPassword')
  Rules        = @{
    PSAlignAssignmentStatement = @{
      Enable         = $true
      CheckHashtable = $true
    }
    PSPlaceCloseBrace          = @{
      Enable             = $true
      NoEmptyLineBefore  = $false
      IgnoreOneLineBlock = $true
      NewLineAfter       = $true
    }
    PSPlaceOpenBrace           = @{
      Enable             = $true
      OnSameLine         = $true
      NewLineAfter       = $true
      IgnoreOneLineBlock = $true
    }
    PSAvoidLongLines           = @{
      Enable            = $true
      MaximumLineLength = 80
    }
  }
}
Class foo {
  [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidLongLines", "")]
  [String]output () {
    $output = "a book is a book is a book. but this report on the activities of a company is"
    return $output
  }
}

Expected behavior

0 warnings

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSAvoidLongLines                    Warning      test.ps1   4     Line exceeds the configured maximum length of 80 characters
1 rule violations found.    Severity distribution:  Error = 0, Warning = 1, Information = 0

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Darwin 17.7.0 Darwin Kernel Version 17.7.0: Wed May 27 17:00:02 PDT 2020; root:xnu-4570.71.80.1~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0

See also #1586 for initial report since this issue was closed i opened a new one and provided clear repo steps.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.