-1

I'm trying to implement SQLFLUFF linter on a certain directory (models/market) on a repo. I'm using this command pre-commit run --files models/market/ what I see is that it is skipping .sql files inside the directory showing this message:

sqlfluff-lint........................................(no files to check)Skipped

while this path includes multiple sql files. here is the pre-commit-config.yaml file:

repos:
  - repo: https://github.com/sqlfluff/sqlfluff
    rev: 2.1.3
    hooks:
      - id: sqlfluff-lint
        verbose: true
        additional_dependencies: [
          'dbt-bigquery==1.5.1',
          'sqlfluff-templater-dbt==2.1.3'
        ]

it is worth noting that this path is not included in .sqlfluffignore

I tried various commands like the ones in here: https://github.com/pre-commit/pre-commit/issues/1173

What I expect is to have SQLFLUFF lint my sql files in a certain directory that it's path is mentioned.

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Masoud
  • 1
  • 3

1 Answers1

1

the --files argument takes files -- you've passed it a single directory

try instead pre-commit run --files $(git ls-files -- models/market)

and before you suggest "it should just recurse" there are special files in git that are directories -- notably submodules -- and there's special meaning for those files.


disclaimer: I wrote pre-commit

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
  • Thank you anthony, can you please help me with this issue as well? https://stackoverflow.com/questions/76847893/sqlfluff-doesnt-parse-dbt-macros-to-fix-even-though-they-are-not-ignored-in-sq – Masoud Aug 06 '23 at 21:53