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

Behavior not supported, please either only include (VALIDATE=true) or exclude (VALIDATE=false) linters, but not both #5567

Closed
1 task done
alexanderbazhenoff opened this issue Apr 23, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@alexanderbazhenoff
Copy link

alexanderbazhenoff commented Apr 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Hi, it's me again :) Pushed a changes in two groovy projects, using the latest image in our GitLab CI. First one is ok (pastebin), second is (pastebin):

Behavior not supported, please either only include (VALIDATE=true) or exclude (VALIDATE=false) linters, but not both

I'm pretty sure I wasn't duplicate anything. Here is my GitLab CI extend:

# Didn't removed yet a workaround of ruff cache bug
.super_linter_clean_up: &super_linter_clean_up |
  sudo rm -rf ${SUPER_LINTER_MYPY_CACHE_FOLDER} ${SUPER_LINTER_LOG_FILE} ${SUPER_LINTER_RUFF_CACHE_FOLDER} || true

.ci_super_linter:
  stage: lint
  before_script:
    - *super_linter_clean_up
    - docker pull ${SUPER_LINTER_DOCKER_IMAGE}
  script:
    - docker run -e RUN_LOCAL=true
        -e LINTER_RULES_PATH=${SUPER_LINTER_RULES_PATH}
        -e ACTIONS_RUNNER_DEBUG=${SUPER_LINTER_ACTIONS_RUNNER_DEBUG}
        -e LOG_FILE=${SUPER_LINTER_LOG_FILE}
        -e USE_FIND_ALGORITHM=${SUPER_LINTER_USE_FIND_ALGORITHM}
        -e VALIDATE_PYTHON_MYPY=${SUPER_LINTER_VALIDATE_PYTHON_MYPY}
        -e CREATE_LOG_FILE=${SUPER_LINTER_CREATE_LOG_FILE}
        -e VALIDATE_JSCPD=${SUPER_LINTER_VALIDATE_JSCPD}
        -v ${CI_PROJECT_DIR}:/tmp/lint ${SUPER_LINTER_DOCKER_IMAGE}
  variables:
    SUPER_LINTER_DOCKER_IMAGE: 'ghcr.io/super-linter/super-linter:latest'
    SUPER_LINTER_RULES_PATH: .linters
    SUPER_LINTER_MYPY_CACHE_FOLDER: .mypy_cache
    SUPER_LINTER_RUFF_CACHE_FOLDER: .ruff_cache
    SUPER_LINTER_ACTIONS_RUNNER_DEBUG: 'false'
    SUPER_LINTER_CREATE_LOG_FILE: 'true'
    SUPER_LINTER_LOG_FILE: super-linter.log
    SUPER_LINTER_USE_FIND_ALGORITHM: 'true'
    SUPER_LINTER_VALIDATE_PYTHON_MYPY: 'false'
    SUPER_LINTER_VALIDATE_JSCPD: 'true'

Also .groovylintrc.json, .yaml-lint.yml and an empty .gitleaks.toml (only comments inside).

Looks like this is a v6.4.1 (iamge pull ghcr.io/super-linter/super-linter:latest).

Really curious what's wrong?

super-linter-latest-bug

I ran it once again in DEBUG mode (pastebin):

still no attempts to lint a only groovy file in src/org.company folder. I have switched to v6.4.0 and the error was the same but colored (BTW, why it's colored?):

super-linter-6 4 0

Also v6.3.1, v6.3.0, v6.2.0, v6.1.1, v6.1.0, v6.0.0...

I also removed my .gitleaks.toml:

# See example: https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
#[allowlist]
#paths = [
#    '''some_file.sh''',
#]

and continue searching for lower version. v5.7.2 is also failed.

Then I mentioned that VALIDATE_JSCPD=false in my first project (which is ok). So I turned off them and switched to the latest super-linter, it's pass!

super-linter-no-jscpd-ok

Any ideas about JSCPD?

Expected Behavior

Expected to start npm-groovy-lint at least, but looks like it's failed on JSCPD.

Super-Linter version

v5.7.2...v6.4.1

Relevant log output

Pastebin links are in 'Current Behavior' section.

Steps To Reproduce

The main problem this project can't be a public. But I have a project with the same language and project structure.

Anything else?

Don't know ¯\_(ツ)_/¯

@alexanderbazhenoff alexanderbazhenoff added the bug Something isn't working label Apr 23, 2024
@echoix
Copy link

echoix commented Apr 23, 2024

The error message matches what your configuration does incorrectly: you validate jscpd, and not mypy.

You can either 1) enable them one by one: once a true variable exists, it means the default enablement for all linters is false,
Or 2) disable them one by one: once a false variable exists, it means that all linters are enabled by default.

That's why you can't mix both, how would you distinguish between these two modes? By alphabetical order? By the first variable passed? How to keep the order? It doesn't make sense...

So, in your environment vars:

    SUPER_LINTER_VALIDATE_PYTHON_MYPY: 'false'
    SUPER_LINTER_VALIDATE_JSCPD: 'true'

Choose one of them according to the scenario you want (all except one, or none except one), and remove either

        -e VALIDATE_PYTHON_MYPY=${SUPER_LINTER_VALIDATE_PYTHON_MYPY}

Or

        -e VALIDATE_JSCPD=${SUPER_LINTER_VALIDATE_JSCPD}

From

script:
    - docker run -e RUN_LOCAL=true
        -e LINTER_RULES_PATH=${SUPER_LINTER_RULES_PATH}
        -e ACTIONS_RUNNER_DEBUG=${SUPER_LINTER_ACTIONS_RUNNER_DEBUG}
        -e LOG_FILE=${SUPER_LINTER_LOG_FILE}
        -e USE_FIND_ALGORITHM=${SUPER_LINTER_USE_FIND_ALGORITHM}
        -e VALIDATE_PYTHON_MYPY=${SUPER_LINTER_VALIDATE_PYTHON_MYPY}
        -e CREATE_LOG_FILE=${SUPER_LINTER_CREATE_LOG_FILE}
        -e VALIDATE_JSCPD=${SUPER_LINTER_VALIDATE_JSCPD}
        -v ${CI_PROJECT_DIR}:/tmp/lint ${SUPER_LINTER_DOCKER_IMAGE}

@alexanderbazhenoff
Copy link
Author

@echoix Thanks for the quick reaction!
I already get this it was jscpd (please reload page, I have updated an info).

But how to disable MYPY and JSCPD both?

@echoix
Copy link

echoix commented Apr 23, 2024

You can have multiple linters set to false.

Following your pattern (if the quoting works correctly)

    SUPER_LINTER_VALIDATE_PYTHON_MYPY: 'false'
    SUPER_LINTER_VALIDATE_JSCPD: 'false'

That would mean you enable everything except these two, and new linters that would be added in next (minor) releases would be enabled too.

@alexanderbazhenoff
Copy link
Author

Great, thank you!

PS: Previous versions of GitLab (don't know about 16.7+) failed on parsing boolean env variables inside a yaml. So quoting was a solution.

@echoix
Copy link

echoix commented Apr 23, 2024

I've never really written any workflow/pipeline for GitLab yet, I just followed the contents of the config yaml.

@ferrarimarco
Copy link
Collaborator

Thanks @echoix for your help here :)

@echoix
Copy link

echoix commented Apr 23, 2024

You're welcome everyone! It was an easy one here.

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

3 participants