Skip to content

Invoke-ScriptAnalyzer : 'count' must be non-negative. #1067

@KyleMartin901

Description

@KyleMartin901

I get the error Invoke-ScriptAnalyzer : 'count' must be non-negative. when I have the setting PSAlignAssignmentStatement enabled for CheckHashTable and a hash is on the same line rather then a new line. If CheckHashTable is set to false there is no error.

Steps to reproduce

I have created a sample project that can be used to reproduce the error at https://github.com/KyleMartin901/km-psscript

Expected behavior


Actual behavior

Invoke-ScriptAnalyzer : 'count' must be non-negative.
Parameter name: count
At line:1 char:1
+ Invoke-ScriptAnalyzer -Path Test-Func.ps1 -Settings psscriptanalyzers ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (/temp/scripts/Test-Func.ps1:String)[Invoke-ScriptAnalyzer], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand

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                      6.0.4
PSEdition                      Core
GitCommitId                    v6.0.4
OS                             Linux 4.9.93-linuxkit-aufs #1 SMP Wed Jun 6 16...
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.17.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions