feat: Ability to whitelist only specific model patterns (#289)#300
feat: Ability to whitelist only specific model patterns (#289)#300mbkloster wants to merge 3 commits into
Conversation
If given, models annotated must match a given set of patterns
|
Sorry for the delay on this. I have looked at the PR a few times and it does make sense. I just need to take some time on how to best handle this, since it seems like there's demand for being able to filter models/files to annotate (allow list) as well as filter to ignore (deny list). @OdenTakashi do you have any thoughts on how we might want to handle this? |
|
Thanks for opening this, @mbkloster!
@drwl I agree — and given that PR #267 is already exploring the deny side, I've been thinking about how we might approach this:
Would love to hear your thoughts, @drwl |
|
I have been thinking through this and the other issues. In the end, it would be great to move away from option flags towards an explicit structure for controlling what does and does not get annotated. Do let me know what you think. Note: I used AI to create the proposals. How I think the ideal pipeline could be: The PipelineThese are two options for handling exclusion Option A — Unified ExclusionA single # .annotaterb.yml
exclude_patterns:
- "**/*.spec.rb" # prevents spec files from being treated as models
- "spec/billing/**/*" # prevents billing-related specs from being annotatedHow it works:
Pros:
Cons:
Option B — Separate Exclusion OptionsTwo distinct options target different layers of the pipeline explicitly. # .annotaterb.yml
# Affects model discovery only — prevents files from being loaded as models
exclude_model_patterns:
- "**/*.spec.rb"
# Affects related file annotation only — models are still processed, but
# matching related files are skipped
exclude_related_file_patterns:
- "spec/billing/**/*"How it works:
Pros:
Cons:
|
Implements #289
Adds a new parameter which, if given, restricts models annotated to match a given set of patterns.
I added both an integration spec and a (much simpler) unit test to this, but let me know if there are patterns or approaches you'd like to see tested separately. I was able to verify that this works on the sample project in this repo.