Skip to content
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

MEGALINTER_FILES_TO_LINT variable doesn't work as expected #1983

Closed
kcfedun-fincad opened this issue Oct 20, 2022 · 1 comment
Closed

MEGALINTER_FILES_TO_LINT variable doesn't work as expected #1983

kcfedun-fincad opened this issue Oct 20, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@kcfedun-fincad
Copy link

kcfedun-fincad commented Oct 20, 2022

Describe the bug

When calling the mega-linter-runner from the CLI and passing a list of files as positional arguments, these files get joined by the mega-linter-runner/lib/runner.js at https://github.com/oxsecurity/megalinter/blob/main/mega-linter-runner/lib/runner.js#L154. This results in the following being passed to the docker run command: -e MEGALINTER_FILES_TO_LINT=".mega-linter.yml,.pre-commit-config.yaml,app.py".

Expected behaviour

The expectation is that megalinter will run its checks against the list of files passed into it.

Actual behaviour

Megalinter only runs it's checks against .pre-commit-config.yaml (in this example), and throws the following warning messages:

[File listing] Input file /tmp/lint/".mega-linter.yml not found
[File listing] Input file /tmp/lint/app.py" not found

Notice the first warning is due to the first filename being pre-pended with a ", and the second is due to the filename appended with a ". This is cause by the creating of the env var at https://github.com/oxsecurity/megalinter/blob/main/mega-linter-runner/lib/runner.js#L154 and/or the unpacking of the list at https://github.com/oxsecurity/megalinter/blob/main/megalinter/config.py#L136.

To Reproduce

I discovered this when trying to run megalint via a pre-commit hook with the pass_filenames argument set at true. Pre-commit passes the list of stages files as a list of positional arguments to the command being called.

One can easily reproduce this issue by running something similar to npx -- mega-linter-runner --remove-container --flavor python --fix file1.py file2.py file3.py

@kcfedun-fincad kcfedun-fincad added the bug Something isn't working label Oct 20, 2022
@Kurt-von-Laven
Copy link
Collaborator

This is a very helpful and greatly appreciated duplicate of #1942 that adds a lot of clarity. I'm closing this simply for the sake of bookkeeping, but will continue the discussion on the original issue when I get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants