Skip to content

CodeFormattingOTBS settings preset always fails due to conflicting rules #1556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RylandDeGregory opened this issue Jul 29, 2020 · 5 comments

Comments

@RylandDeGregory
Copy link

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

@ghost ghost added the Needs: Triage 🔍 label Jul 29, 2020
@bergmeister
Copy link
Collaborator

bergmeister commented Jul 29, 2020

This looks like a duplicate of #769, would you agree?
I think a fix for this is not very easy because it involves both rules knowing about each other. A possible but expensive solution would be to try merge the rules together into one, which is something that even the previous maintainer of PSSA has suggested to do.
cc @rjmholt as some food for thought for PSSA v2 API

@RylandDeGregory
Copy link
Author

This looks like a duplicate of #769, would you agree?
I think a fix for this is not very easy because it involves both rules knowing about each other. A possible but expensive solution would be to try merge the rules together into one, which is something that even the previous maintainer of PSSA has suggested to do.
cc @rjmholt as some food for though for PSSA v2 API

I'd agree that it is a duplicate. But, I'd also pose 2 question to the maintaining team.

  1. If this has been a known issue for over 3 years with 7 duplicate issues, why has it not been prioritized for resolution?
  2. As mentioned in Unable to use both AlignAssignmentStatement and UseConsistentWhitespace rules #769 by @jayvdb, why are the default settings profiles all still using these conflicting rules together? It seems that users are being guided to failure by including multiple broken default configurations.

@JamesWTruher
Copy link
Contributor

@RylandDeGregory please feel free to provide a PR to address this issue.

@RylandDeGregory
Copy link
Author

@RylandDeGregory please feel free to provide a PR to address this issue.

#1559

@ghost
Copy link

ghost commented Jul 31, 2020

This issue has been marked as duplicate and has not had any activity for 1 day. It will be closed for housekeeping purposes.

@ghost ghost closed this as completed Jul 31, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants