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

SQLFluff only ever reports 1 issue #1460

Closed
tdstark opened this issue May 6, 2022 · 2 comments · Fixed by #1462
Closed

SQLFluff only ever reports 1 issue #1460

tdstark opened this issue May 6, 2022 · 2 comments · Fixed by #1462
Labels
bug Something isn't working

Comments

@tdstark
Copy link
Contributor

tdstark commented May 6, 2022

Describe the bug
Regardless of the number of linting issues uncovered by SQLFluff, Megalinter only ever identifies that there is a maximum of one issue when run as part of Github Actions. This is a problem because SQL_SQLFLUFF_DISABLE_ERRORS_IF_LESS_THAN becomes redundant.

To Reproduce
Steps to reproduce the behavior:

  1. Add the Github Actions config provided below to a .build file
  2. Add problematic Redshift sql to project
  3. Allow Megalinter to run SQLFluff

Expected behavior
Megalinter should flag one issue per issue identified by SQLFluff.

Screenshots
+----SUMMARY-+----------+---------------+-------+-------+--------+--------------+
| Descriptor | Linter | Mode | Files | Fixed | Errors | Elapsed time |
+------------+----------+---------------+-------+-------+--------+--------------+
| ❌ SQL | sqlfluff | list_of_files | 247 | | 1 | 1.34s |
+------------+----------+---------------+-------+-------+--------+--------------+

Additional context
Here is my Github Actions config snippet:

  lint_sql:
    name: Lint SQL
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: sqlfluff_redshift
        uses: megalinter/megalinter/flavors/python@v5
        env:
          DEFAULT_BRANCH: master
          GITHUB_TOKEN: ${{ secrets.CII_GITHUB_DEPLOYMENT_TOKEN }}
          GITHUB_COMMENT_REPORTER: false
          PRINT_ALPACA: false
          VALIDATE_SQL_SQLFLUFF: true
          SQL_SQLFLUFF_ARGUMENTS: --dialect=redshift
@tdstark tdstark added the bug Something isn't working label May 6, 2022
@nvuillam
Copy link
Member

nvuillam commented May 6, 2022

Some of the linters are not configured yet to list the number of errors, so it always displays one
This is the case for sqlfluff

https://github.com/megalinter/megalinter/blob/ffce8af23f5d2ba5d7555f23c30fd4107c22ec5b/megalinter/descriptors/sql.megalinter-descriptor.yml#L26

This can be done configuring descriptors properties cli_lint_errors_count and cli_lint_errors_regex ( example ) that are used to count the errors from output text file

Maybe you would like to make a PR ?

If not, myself or another contributor can do it someday :)

@tdstark
Copy link
Contributor Author

tdstark commented May 6, 2022

I can take a stab at a PR.

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

Successfully merging a pull request may close this issue.

2 participants