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

Pre-commit passes a list of files to lint but csvlint can only accept one #288

Open
jamesmelville-gds opened this issue Jan 16, 2024 · 1 comment

Comments

@jamesmelville-gds
Copy link

Expected Behaviour

When running csvlint in a pre-commit hook pre-commit will pass a list of files to it as seperate args. csvlint should take the list and generate a response for all. cfn-lint has an example of this support https://github.com/aws-cloudformation/cfn-lint#basic-usage

Current Behaviour (for problems)

csvlint errors:

ERROR: "csvlint validate" was called with arguments ["file1.csv", "file2.csv"]
Usage: "csvlint myfile.csv OR csvlint http://example.com/myfile.csv"

Steps to Reproduce (for problems)

Use a pre-commit config like:

---
default_language_version:
  ruby: 2.7.8
repos:
- repo: https://github.com/Data-Liberation-Front/csvlint.rb
  rev: v1.3.0
  hooks:
    - id: csvlint
      name: lint files/*.csv
      files: 'file.*\.csv'
      pass_filenames: true

against files like:

file1.csv
file2.csv
file3.csv

Current workaround is to use xargs to run csvlint against each file:

    - id: csvlint
      name: lint files/*.csv
      files: 'file.*\.csv'
      entry: bash -xc 'echo "$@" | xargs -n 1 -I filename csvlint filename --schema=schema/csv' --
@huwd
Copy link

huwd commented Apr 11, 2024

Had a look at the usage, we sure this is expected behavior we'd want here @jamesmelville-gds?

Seems like the expected usage here is one linting pass per CSV.
I imagine it'd be easy to get CSV lint to parse an array of inputs here and go through them in batch...

but then wondering if that breaks the model, are linting responses now to be grouped around an offending file, or clumped into "you've got these problems in that lump". 🤔

Not sure what @Floppy thinks, but perhaps us using bash-fu to enumerate all our CSVs and lint each separately is OK?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants