question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CodeFormattingOTBS settings preset always fails due to conflicting rules

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bergmeistercommented, Jul 30, 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

0reactions
msftbot[bot]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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NVENC streaming Preset and Multipass Mode
Hi! I want to ask about these two settings: - Preset - Multipass mode I use NVENC and Preset P5: Slow (Good Quality)...
Read more >
How to Fix OBS “Encoding Overloaded” Issue [2023]
Go to Settings, open the Video tab and lower the output resolution. Then select Common FPS Values and choose 30 or less. Open...
Read more >
OBS Encoding Overloaded? Here are 9 Methods to Fix It
Method 2: Lower Frame Rate; Method 3: Change Encoder Preset; Method 4: Use Hardware Encoding; Method 5: Change Process Priority; Method 6: Close ......
Read more >
Code Formatting | The IntelliJ IDEA Blog
Let's walk through setting specific formatting for use with Java 8 Streams. We'll change the settings so that Stream operations are always ......
Read more >
IntelliJ IDEA: Coding style and code formatting
Code formatting in IDEA. After importing the project, press Ctrl+N and go to the AppTest class. This is the default test class. It...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found