`annotaterb models --delete` doesn't remove annotations from files excluded via `exclude_*`
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Start with lib/annotate_rb/model_annotator/project_annotation_remover.rb and the RelatedFilesListBuilder#build implementation it uses; trace how exclude_* options affect the files visited during removal. Check the related unit tests and add coverage for excluded file types. Done means annotaterb models --delete removes existing annotations from excluded related files without changing where annotations are added.
Written by the indexing model from the issue text.
Description
Summary
When a related file type is excluded from annotation (e.g. exclude_tests: true), annotaterb models --delete does not remove annotations that were previously written to those files. The annotations become orphaned, and there's no built-in way to clean them up other than temporarily reverting the config.
Steps to reproduce
- With
exclude_tests: false(the default), annotate — the model and its test files get an annotation block. - Decide you no longer want annotations in test files and set
exclude_tests: true. - Run
annotaterb models --delete.
Expected: the annotation blocks are removed from the test files as well.
Actual: the model/fixture annotations are removed, but the test files keep their (now stale) annotation blocks. The only workaround is to set exclude_tests: false, run --delete, then set it back to true.
The same applies to any related type that can be excluded (fixtures, factories, serializers, scaffolds, controllers, helpers).
Root cause
ProjectAnnotationRemover#build_instructions_for_file builds its related-file list with the same RelatedFilesListBuilder that is used for annotating:
RelatedFilesListBuilder#build gates each related file type on the exclude_* options, so an excluded type is never added to the list — and removal therefore never visits it.
Proposed fix
The exclude_* options describe where annotations should be added; they shouldn't block removal. When removing, the builder should reach every related file type regardless of the exclude settings (removing an annotation from a file that has none is a no-op).
I have a small patch + unit test ready and am happy to open a PR if this direction sounds good to you.
- Dominant language
- Ruby
- Stars
- 624
- Forks
- 95
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from drwl/annotaterb
-
additional_file_patterns no longer matches files outside empty root_dirPossibly taken @Shaisolaris claimed this 3 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
drwl/annotaterb#406 ·
Maintainers usually reply within 2 days
-
`v4.25.0`: enum columns declared with a Rails-side `default:` still annotate the raw value instead of the labelPossibly taken @xanagi claimed this 3 days ago. Open
Difficulty 3/5 Half a day Newbie friendliness 62/100
drwl/annotaterb#408 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
drwl/annotaterb#369 · 1 reaction ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
drwl/annotaterb#323 · 1 comment ·
Maintainers usually reply within 2 days
-
Improve Documentation for YAML and CLI OptionsMay be free again @OdenTakashi claimed this 194 days ago, and no pull request is open. Open
drwl/annotaterb#312 · 8 comments · 1 assignee ·
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
:bank: debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
cucumber/cucumber-ruby-core#346 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
TheOdinProject/curriculum#31467 · 2 comments ·
Maintainers usually reply within 1 day
-
message-patterns
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
sisimai/rb-sisimai#468 ·