-
-
Notifications
You must be signed in to change notification settings - Fork 241
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
Format powershell linter output into terminal-wide table #3318
Conversation
Query the width of the terminal and enforce it for the output of the powershell linter. This uses the following cmdlets: - Format-Table is used for a better table output, made aware of the extra width available. - Out-String is explicity set to use the width of the terminal coming from Python.
I see that the tests fail. This is because the output has changed and is not clamped to 80 characters anymore. An "easy" solution would be to arrange for the content of the ERROR-POWERSHELL_POWERSHELL.txt file to be the same as the one when running the tests at GitHub. Where can I find the output in the GitHub workflow logs/files? A better solution, i.e. working in all cases, would require to add a new environment variable called
Which solution is best and how can we enforce the content of an environment variable during a test? |
@efrecon The error seems related to the fact that the terminal is not tty (basically means that it is not interactive) if self.linter_name == "powershell":
# Format output to fit in terminal, respecting the terminal width.
# For more info: https://stackoverflow.com/a/76889369
> size = os.get_terminal_size()
E OSError: [Errno 25] Not a tty You should implement a fallback with a default size, or even just define a default size, as terminal will never be interactive, and it should work :) |
It has defaults when no TTY present, same as PowerShell
This count the lines beginning with all known severity errors
…ter into better-powershell-output * 'better-powershell-output' of github.com:efrecon/megalinter: [automation] Auto-update linters version, help and documentation (oxsecurity#3338) Bump peter-evans/create-pull-request from 5 to 6 (oxsecurity#3337) Bump yeoman-environment from 4.2.1 to 4.3.0 in /mega-linter-runner (oxsecurity#3333) [automation] Auto-update linters version, help and documentation (oxsecurity#3334) [automation] Auto-update linters version, help and documentation (oxsecurity#3331)
Now integrates fixes for #3320 as well |
sorry for the delay, i'm very busy these day ^^ |
Each part of the pipeline is documented to facilitate understanding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot @efrecon for your hardwork on this PR :)
Fixes #3313 and #3320
Proposed Changes
Improve the output format of the
powershell
linter by ensuring that the columns utilise the entire terminal width. This improves readability of both the description message and the location of the offending problem. Extra care is necessary to bypass a known powershell bug on UNIX-like systems.Readiness Checklist
Author/Contributor
Reviewing Maintainer
breaking
if this is a large fundamental changeautomation
,bug
,documentation
,enhancement
,infrastructure
, orperformance