Skip to content

Conversation

@llaville
Copy link
Collaborator

Fixes #4610

Proposed Changes

  1. Follow suggestion of @nvuillam

Readiness Checklist

Author/Contributor

  • Add entry to the CHANGELOG listing the change and linking to the corresponding issue (if appropriate)
  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

@llaville
Copy link
Collaborator Author

llaville commented Jan 28, 2025

/build

Command run output
Build command workflow started.
Installing dependencies
Running script ./build.sh
Build command workflow completed without updating files.

@github-actions
Copy link
Contributor

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ API spectral 1 0 1.67s
⚠️ BASH bash-exec 6 1 0.02s
✅ BASH shellcheck 6 0 0.21s
✅ BASH shfmt 6 0 0 0.94s
✅ COPYPASTE jscpd yes no 2.88s
✅ DOCKERFILE hadolint 129 0 25.8s
✅ JSON jsonlint 20 0 0.4s
✅ JSON v8r 22 0 15.61s
⚠️ MARKDOWN markdownlint 267 0 302 23.04s
✅ MARKDOWN markdown-table-formatter 267 0 0 161.72s
⚠️ PYTHON bandit 215 66 3.45s
✅ PYTHON black 215 0 0 4.73s
✅ PYTHON flake8 215 0 2.31s
✅ PYTHON isort 215 0 0 1.42s
✅ PYTHON mypy 215 0 17.25s
✅ PYTHON pylint 215 0 35.12s
✅ PYTHON ruff 215 0 0 0.55s
✅ REPOSITORY checkov yes no 37.15s
✅ REPOSITORY git_diff yes no 1.09s
⚠️ REPOSITORY grype yes 24 13.91s
✅ REPOSITORY secretlint yes no 12.58s
✅ REPOSITORY trivy yes no 15.79s
✅ REPOSITORY trivy-sbom yes no 0.27s
⚠️ REPOSITORY trufflehog yes 1 53.79s
✅ SPELL cspell 718 0 12.56s
⚠️ SPELL lychee 349 27 5.31s
✅ XML xmllint 3 0 0 0.88s
✅ YAML prettier 160 0 0 4.16s
✅ YAML v8r 102 0 30.43s
✅ YAML yamllint 161 0 3.32s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2025

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
✅ API spectral 1 0 1.73s
⚠️ BASH bash-exec 6 1 0.02s
✅ BASH shellcheck 6 0 0.18s
✅ BASH shfmt 6 0 0 0.83s
✅ COPYPASTE jscpd yes no 2.9s
✅ DOCKERFILE hadolint 129 0 24.99s
✅ JSON jsonlint 20 0 0.2s
✅ JSON v8r 22 0 14.99s
⚠️ MARKDOWN markdownlint 267 0 302 21.39s
✅ MARKDOWN markdown-table-formatter 267 0 0 164.44s
⚠️ PYTHON bandit 215 66 3.87s
✅ PYTHON black 215 0 0 4.37s
✅ PYTHON flake8 215 0 2.33s
✅ PYTHON isort 215 0 0 1.44s
✅ PYTHON mypy 215 0 15.38s
✅ PYTHON pylint 215 0 28.91s
✅ PYTHON ruff 215 0 0 0.85s
✅ REPOSITORY checkov yes no 33.6s
✅ REPOSITORY git_diff yes no 0.83s
⚠️ REPOSITORY grype yes 24 14.44s
✅ REPOSITORY secretlint yes no 11.43s
✅ REPOSITORY trivy yes no 18.35s
✅ REPOSITORY trivy-sbom yes no 0.29s
⚠️ REPOSITORY trufflehog yes 1 54.07s
✅ SPELL cspell 718 0 13.26s
⚠️ SPELL lychee 349 27 25.06s
✅ XML xmllint 3 0 0 0.94s
✅ YAML prettier 160 0 0 3.62s
✅ YAML v8r 102 0 25.65s
✅ YAML yamllint 161 0 2.52s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@nvuillam
Copy link
Member

It seems your regex doesn't work with

PHP CS Fixer 3.68.3 Persian Successor by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.4.3

maybe the colors in the output ?

@echoix
Copy link
Collaborator

echoix commented Jan 28, 2025

It seems your regex doesn't work with

PHP CS Fixer 3.68.3 Persian Successor by Fabien Potencier, Dariusz Ruminski and contributors.

PHP runtime: 8.4.3

maybe the colors in the output ?

If so, can you call the version with no colors to help you out?

@llaville
Copy link
Collaborator Author

Ok error came from colors ouput.

I confirmed because I've disabled it locally on a slim linter php-cs-fixer linter only and run tests with NO_COLOR=true (https://no-color.org/) env var supported by this linter.

Now, the ultimate question is : how to disable it only for getting version number but keep color output for linter results ?

@echoix
Copy link
Collaborator

echoix commented Jan 28, 2025

There's a way to set either arguments, extra arguments, or even the executable to execute for getting the version.
https://megalinter.io/latest/json-schemas/descriptor.html#linters_items_cli_executable_version

So, with that, set it to send the env var inline before calling the tool, I think it would work

@echoix
Copy link
Collaborator

echoix commented Jan 28, 2025

Or you adapt the regex to support/ignore the color.. if there's a general way, it could apply to the whole Megalinter, to ignore ANSI escape codes

@llaville
Copy link
Collaborator Author

Or you adapt the regex to support/ignore the color.. if there's a general way, it could apply to the whole Megalinter, to ignore ANSI escape codes

If there is a solution, I'm glad to hear it !

@llaville
Copy link
Collaborator Author

Ok I think I got the solution, I'm on way to test it ...

@llaville
Copy link
Collaborator Author

Patch is :

diff --git a/megalinter/Linter.py b/megalinter/Linter.py
index 2656e7eba4..d09518d704 100644
--- a/megalinter/Linter.py
+++ b/megalinter/Linter.py
@@ -1149,6 +1149,7 @@ class Linter:
         subprocess_env = {
             **config.build_env(self.request_id, True, self.unsecured_env_variables),
             "FORCE_COLOR": "0",
+            "NO_COLOR": "true",
         }
         try:
             process = subprocess.run(

And result by image :

no_color__phpcsfixer

@llaville
Copy link
Collaborator Author

Ready for code review (acceptance) !

Copy link
Member

@nvuillam nvuillam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have found a way without addint a variable for all linters but... It's good enough for me, thanks for the PR :)

@nvuillam nvuillam merged commit 42d85c5 into main Jan 28, 2025
130 checks passed
@nvuillam nvuillam deleted the fix-phpcsfixer-linter-version branch January 28, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP CS Fixer linter version available is not correct since running on PHP 8.4 runtime

4 participants