Skip to content

CodeFormattingOTBS settings preset always fails due to conflicting rules #1556

Closed
@RylandDeGregory

Description

@RylandDeGregory

Steps to reproduce

  1. Define a script that contains custom object syntax
# Build output object and add to array
$ServerArray += [PSCustomObject]@{
    ComputerName = $VMName
    vCenterName = $vCenter.name.Split('@')[1]
}
  1. Run PSScriptAnalyzer with the built-in 'CodeFormattingOTBS' settings preset.
Invoke-ScriptAnalyzer -path ./test.ps1 -Settings 'CodeFormattingOTBS'
  1. Note that PSAlignAssignmentStatement rule throws a Warning.

  2. Correct error by aligning assignment statements.

# Build output object and add to array
$ServerArray += [PSCustomObject]@{
    ComputerName = $VMName
    vCenterName  = $vCenter.name.Split('@')[1]
}
  1. Run PSScriptAnalyzer with the built-in 'CodeFormattingOTBS' settings preset again.
Invoke-ScriptAnalyzer -path ./test.ps1 -Settings 'CodeFormattingOTBS'

Expected behavior

No errors.

Actual behavior

PSUseConsistentWhitespace throws an error due to the multiple spaces before the assignment operator =.

Screen Shot 2020-07-29 at 10 47 13 AM

This also happens when using the -Fix parameter of Invoke-ScriptAnalyzer. It will simply switch back and forth between the two errors each time you execute the command with -Fix.

Environment data

MacOS Catalina 10.15.5

Screen Shot 2020-07-29 at 10 48 19 AM

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