adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.82k stars 269 forks source link

yamllint disable-line doesn't affect syntax rule #338

Closed sfuerte closed 3 years ago

sfuerte commented 3 years ago

As per https://bitbucket.org/product/features/pipelines/integrations?p=snyk/snyk-scan have the following in my bitbucket-pipelines.yml:

...
        script:
          - docker build
              --compress
              --force-rm
              --pull
              --build-arg ...
              --tag $IMAGE_NAME:$BITBUCKET_COMMIT .
          # Bitbucket internal image? https://bitbucket.org/product/features/pipelines/integrations?p=snyk/snyk-scan
          # yamllint disable-line
          – pipe: snyk/snyk-scan:0.4.4
            variables:
              SNYK_TOKEN: $SNYK_TOKEN
              ORGANIZATION: $SNYK_ORGANIZATION
              LANGUAGE: “docker”
              IMAGE_NAME: $IMAGE_NAME
              TARGET_FILE: “Dockerfile”
...

A check fails with:

> yamllint -s  .
./bitbucket-pipelines.yml
  47:11     error    syntax error: expected <block end>, but found '?' (syntax)

tried with # yamllint disable-line both above and on the same line in the end.

> yamllint -v
yamllint 1.25.0
sfuerte commented 3 years ago

an update, placing # yamllint disable-file or # yamllint disable at the top of the file is ignored as well.

perlpunk commented 3 years ago

You have an en-dash in this line:

          – pipe: snyk/snyk-scan:0.4.4

That should be a hyphen instead:

          - pipe: snyk/snyk-scan:0.4.4

That's a syntax error, and yamllint can only ignore lines if the content is valid, I guess.

The error message could be improved, for sure, but that's a pyyaml issue.

sfuerte commented 3 years ago

@perlpunk, good eye and thanks a lot for the hint! I guess it would've taken me a while, especially on Friday night.