Skip to content

Commit

Permalink
[MegaLinter] Apply linters fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored and megalinter-bot committed Jun 7, 2024
1 parent 740640d commit 8c44f8f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions megalinter/linters/PowershellLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,21 @@ def build_lint_command(self, file=None):

def format_powershell_output(self, pwsh_script):
if utils.is_ci():
width = 150 # Use a default width in CI environments to prevent output cutoff
width = (
150 # Use a default width in CI environments to prevent output cutoff
)
else:
width = get_terminal_size().columns # Use the terminal width when not in CI

# Format the output to a table with specific columns
pwsh_script += " | Format-Table -AutoSize -Wrap -Property " \
"@{Name='Severity'; Expression={$_.Severity}; Alignment='left'}," \
" @{Name='RuleName'; Expression={$_.RuleName}; Alignment='left'}," \
" @{Name='ScriptName'; Expression={$_.ScriptName}; Alignment='left'}," \
" @{Name='Line'; Expression={$_.Line}; Alignment='right'}," \
" @{Name='Message'; Expression={$_.Message}; Alignment='left'}"
pwsh_script += (
" | Format-Table -AutoSize -Wrap -Property "
"@{Name='Severity'; Expression={$_.Severity}; Alignment='left'},"
" @{Name='RuleName'; Expression={$_.RuleName}; Alignment='left'},"
" @{Name='ScriptName'; Expression={$_.ScriptName}; Alignment='left'},"
" @{Name='Line'; Expression={$_.Line}; Alignment='right'},"
" @{Name='Message'; Expression={$_.Message}; Alignment='left'}"
)

# Ensure the output string fits within the specified width
pwsh_script += f" | Out-String -Width {width}"
Expand Down

0 comments on commit 8c44f8f

Please sign in to comment.