sbdchd / squawk

🐘 linter for PostgreSQL, focused on migrations
https://squawkhq.com
GNU General Public License v3.0
541 stars 37 forks source link

Failed to find files for provided patterns with pre-commit #363

Open dhakshin32 opened 5 days ago

dhakshin32 commented 5 days ago

I have 1 sql script in my staging directory at the moment (I'm using squawk with pre-commit and I specified the git pre-commit hook to act on all scripts with in my fly away migration folder). If I add this script to my exclude paths or do the following:

excluded_paths = [
    "*.sql"
]

I get the error: Failed to find files for provided patterns: ...

Doesn't it make more sense to exit 0 in this case since no .sql files should be listed/analyzed and therefore there is no error to be thrown? https://github.com/sbdchd/squawk/blob/ca1f346d4a98529418a0ee635efe4e11c5580a86/cli/src/main.rs#L175

The use case for this is: there is currently no way to override if I don't care about the violation. The docs say to usefail_on_violations = false. I add this property and I still getting a violation, causing squawk to fail and exit 1. This prevents me from making a commit since this is a pre-commit hook

chdsbd commented 5 days ago

I think this behavior is mimicking the behavior of ESLint. We should add a flag like they have to handle this: https://eslint.org/docs/latest/use/command-line-interface#--no-error-on-unmatched-pattern