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
Remove color code from super-linter stdout and logfile when not needed #5540
Comments
Hi @ChaosEternal ! I think this is applicable not just for ShellCheck output, but to the whole output. Example:
Anyway, you have a point. |
We may start with checking if we have a terminal: |
A complementary feature may be that the log file should respect the log level, instead of defaulting to |
Where to read for example? :) FYI: if you read a raw output from GitLab CI (for example) you may use some additional browser plugins like RetroTxt for Google Chrome. Full ASCII support on specified URLs available. This plugin is especially useful when you open huge colored ansible logs in raw. As about shellcheck in Super-linter, in previous super-linter versions I used # <your_settings_folder>/.shellcheckrc
# You can set this path via `LINTER_RULES_PATH` env variable:
# https://github.com/super-linter/super-linter#configure-super-linter
format=gcc # Output format (checkstyle, diff, gcc, json, json1, quiet, tty) PS: Hmmm... I have comment here, but it was asked :) |
There are two cases,
i) we have a ci system which have (only) plain log support, those color
code doesn't display correctly
ii) there are machines that want to read the output and make meaningful
suggestions to code reviewers.
…On Tue, Apr 23, 2024 at 11:29 AM Alexander Bazhenov < ***@***.***> wrote:
Hi @ChaosEternal <https://github.com/ChaosEternal>
to read if not from a terminal.
Where to read for example? :)
*FYI:* if you read a raw output from GitLab CI (for example) you may use
some additional browser plugins like RetroTxt
<https://chromewebstore.google.com/detail/retrotxt/gkjkgilckngllkopkogcaiojfajanahn?hl=en-US&utm_source=ext_sidebar>
for Google Chrome. Full ASCII support on specified URLs available.
Something like a .shellcheck file with parameters would probably do,
since Shellcheck doesn't support config file from the box. Or may be a
special variable with options for Shellcheck, but this is a huge work at
the end to made such variables for all linters. Because you should pay
attention on every single linter's output and options set at all:
somethings are acceptable, something will broke wrapper scripts.
—
Reply to this email directly, view it on GitHub
<#5540 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALMFG4S5AQWFVVC4H5DLZ3Y6W2PRAVCNFSM6AAAAABGMY2BXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZRGI2DKMBSGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@ChaosEternal
The issue that's left to address is that we use what each linter emits to stdout and stderr as part of the super-linter stdout and the super-linter log file. Each linter has its own way to deal with emitting (or not) color codes: configuration, command line options, presence of a tty, on unless disabled... This might cause some color codes to be present in the super-linter stdout or in the super-linter log file when you look at each specific linter output. An example of this is Gitleaks. (the following statements are applicable to linters that support color codes) To address this, we would need to account for two cases to avoid getting color codes in the super-linter stdout and super-linter log file when not needed:
|
See my previous reply about this.
For this, parsing text logs is probably too fragile. We might want to have a look at more structured output formats, such as SARIF and JSON for linters that support that, but that's for another feature request, I suppose. :) |
BTW, how to force enable colors now in CI? (Not so big problem, but it's better for us :) |
@alexanderbazhenoff Hi! How are you running super-linter? |
Hi, in GitLab CI as described here. |
@alexanderbazhenoff Can you try allocating a TTY (add |
Is there an existing issue for this?
Current Behavior
The current output from shellcheck has ansi color codes, which makes the output difficult to read if not from a terminal.
Expected Behavior
Ability to remove the ansi-color code.
A flag or a config is good.
Anything else?
No response
The text was updated successfully, but these errors were encountered: