Adds a test keeping new tracker ids out of lib/ - #174
Merged
Merged
Conversation
lib/ moduledocs and comments carry tracker ids that point a reader at an issue instead of saying what the code does. The new test refuses a new one: a committed baseline counts the ids each lib/ file carries today, a count above it fails naming the file and the id, and a count below it fails naming the baseline line to lower, so an id that leaves a file cannot come back unseen. CSS class names of the same shape (sr-only) are excluded by name. Refs: se-l9xx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new test,
StatifierExamples.TrackerIdTest, refuses a new tracker id in any file underlib/. A tracker id is a family tracker prefix, a dash and three or four base36 characters; in a moduledoc or a comment it points a reader at an issue instead of saying what the code does.lib/already carries such ids, so the test works the wayStatifierExamples.PrivateIdTestdoes: a committed baseline,test/fixtures/tracker_id_baseline.txt, counts the ids eachlib/file carries at this commit. A count above the baseline fails, naming the file and the id; a count below it fails too, naming the baseline line to lower or delete, so an id that leaves a file cannot come back unseen. CSS class names of the same shape are excluded by name (sr-only); longer class prefixes such assb-editornever match the shape. The test globslib/at run time, so a file added later is covered the moment it exists.Provenance
lib/as already free of tracker ids. It is not: the ids are in moduledocs and comments acrosslib/statifier_examples/andlib/statifier_examples_web/(the baseline lists every one). A test that forbids every id outright would be red at the tip, so this PR takes the baseline shape ofprivate_id_test.exsinstead, chosen in this PR as a test-shape choice. Rewriting the existing ids into their substance is left as a follow-up; each rewrite lowers a baseline line, and the second assertion makes that lowering required.Checks
charts/fixture.ex's moduledoc, a second copy of an iddocuments.exalready carries, and the id removed fromcharts/fan_out.ex's moduledoc each turned "no lib/ file gains a tracker id" red on its assertion; droppingonlyfrom the excluded class words and shortening the id shape to three characters each turned the pattern test red on its assertion. The one-line notes sit above each test.mix qualitygreen on the committed tree: format, compile, credo, dialyzer, deps, and the full suite with coverage.In-turn review
I re-read the diff against the bead: its acceptance asks for a test that fails when a tracker-id shape appears in a lib/ moduledoc or comment, CSS classes allowed, sabotaged with an injected id and green at the tip. The planted-id sabotage above is the injected id; the
sr-onlyandsb-editornegatives in the pattern test are the CSS allowance; the suite is green at the tip. I checked the prefix list against every family tracker's prefix, and checked every non-id match of the shape inlib/today (there is one,sr-onlyincore_components.ex). The moduledoc's "What it does not catch" list names the known gaps: a prefix not yet listed, an id spelling an excluded class word, and a baseline line added beside a new id.