Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`annotaterb models --delete` doesn't remove annotations from files excluded via `exclude_*`

Open
#340 2 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 2 days

@jeduardo824 is already working on this.

Since Jun 8, 2026.

  • #343 by @jeduardo824 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
rails, ruby
Domain
tooling

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

  1. With exclude_tests: false (the default), annotate — the model and its test files get an annotation block.
  2. Decide you no longer want annotations in test files and set exclude_tests: true.
  3. 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:

https://github.com/drwl/annotaterb/blob/9538099/lib/annotate_rb/model_annotator/project_annotation_remover.rb#L51

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from drwl/annotaterb

All issues in drwl/annotaterb

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.