Skip to content

#554: catch unused motive files via test#863

Merged
yegor256 merged 3 commits intoobjectionary:masterfrom
bibonix:fix-554-orphan-motive-files
May 8, 2026
Merged

#554: catch unused motive files via test#863
yegor256 merged 3 commits intoobjectionary:masterfrom
bibonix:fix-554-orphan-motive-files

Conversation

@bibonix
Copy link
Copy Markdown
Contributor

@bibonix bibonix commented May 8, 2026

@yegor256 this PR addresses #554 by adding PkMonoTest#linksEveryMotiveFileToALint, which walks every .md under src/main/resources/org/eolang/motives/ and asserts that the filename (without .md) is the name() of a lint produced by PkMono. Without this guard, motive files can drift from real lints — exactly what #554 calls out for motives/critical/same-line-names.md.

Summary of changes

  • First commit adds the assertion (initially as MotivesAreUsedTest); it fails on master listing 11 orphan motive names (architect-duplicate, correct-package-meta, lt-incorrect-unlint, noname-attribute, object-does-not-match-filename, one-high-level-object, same-line-names, signed-binding-indexes, test-object-is-not-verb-in-singular, unit-test-without-live-file, zero-version).
  • Second commit makes it pass:
    • rename motives/errors/lt-incorrect-unlint.mdmotives/errors/incorrect-unlint.md, since LtIncorrectUnlint.name() is incorrect-unlint; update LtIncorrectUnlint.motive() to load the renamed resource.
    • delete the empty units/unit-test-missing.md and units/unit-test-without-live-file.md leftovers from 93e7006,
    • delete the documented-but-unimplemented motives critical/same-line-names.md, errors/noname-attribute.md, errors/signed-binding-indexes.md, metas/architect-duplicate.md, metas/correct-package-meta.md, metas/zero-version.md, misc/one-high-level-object.md, names/object-does-not-match-filename.md,
    • delete misc/test-object-is-not-verb-in-singular.md (the disabled LtTestNotVerb per the @todo in PkMono.java),
    • drop the .vale.ini override for the now-deleted same-line-names.md.
  • Third commit moves the assertion into PkMonoTest so jtcop's RuleEveryTestHasProductionClass and RulePresentTense are happy (linksEveryMotiveFileToALint).

Test plan

  • mvn -Dtest='PkMonoTest#linksEveryMotiveFileToALint' test passes against this branch.
  • mvn -Pqulice -DskipTests install is green locally — no qulice violations.
  • MotivesAreUsedTest against master (before commit 2) lists the 11 orphan names from the bug.
  • LtIncorrectUnlintTest, LtAsciiOnlyTest, LintTest, WithoutLintsTest, MonoLintNamesTest continue to pass after the rename.
  • No production code outside LtIncorrectUnlint.motive() references the renamed motive path.

CI status note

The mvn (ubuntu-24.04, macos-15, windows-2022), deep, and reserved jobs fail on this PR with MonoLintsTest.lintsProgramCorrectly and PkByXslTest.doesNotDuplicateDefectsWhenMultipleDefectsOnTheSameLine timing out at 45s — both pre-existing on master (#769) and on every PR (e.g. #862 was merged with the same matrix red), so they are not introduced by this change. ort also reports failure here for reasons I can't pinpoint from the action's truncated output (the action exits 2 minutes in with Process completed with exit code 1, no annotation text); the .ort.yml excludes are unchanged and reuse, qulice, vale, markdown-lint, pdd, xcop, typos, actionlint, yamllint, bashate, shellcheck, copyrights, labeler are all green. Happy to investigate further if you can share the run log.

bibonix added 3 commits May 8, 2026 00:38
… a lint

Add MotivesAreUsedTest, which walks every .md under
src/main/resources/org/eolang/motives/ and fails if its
filename (without .md) is not the name() of a lint produced
by PkMono. Fails on master with the orphan motive files
that objectionary#554 calls out.
…lint motive

- Rename motives/errors/lt-incorrect-unlint.md to incorrect-unlint.md
  to match the lint name returned by LtIncorrectUnlint.name(), and
  update LtIncorrectUnlint.motive() to load the renamed resource.
- Delete motive files that no lint in PkMono references: the empty
  units/unit-test-missing.md and units/unit-test-without-live-file.md
  leftovers, and the documented-but-unimplemented motives for
  same-line-names, noname-attribute, signed-binding-indexes,
  architect-duplicate, correct-package-meta, zero-version,
  one-high-level-object, test-object-is-not-verb-in-singular,
  and object-does-not-match-filename.
- Drop the .vale.ini override for the deleted same-line-names motive.

After this change, MotivesAreUsedTest passes against master.
jtcop expects each test class to have a same-named production
class (RuleEveryTestHasProductionClass) and present-tense test
names (RulePresentTense). Fold the new motive-coverage assertion
into PkMonoTest as linksEveryMotiveFileToALint() and drop the
standalone MotivesAreUsedTest.
@bibonix bibonix force-pushed the fix-554-orphan-motive-files branch from af8c43e to c5f32da Compare May 8, 2026 01:24
@yegor256 yegor256 merged commit 843293c into objectionary:master May 8, 2026
30 of 42 checks passed
@0crat
Copy link
Copy Markdown

0crat commented May 8, 2026

@bibonix Thanks for the contribution! You've earned +12 points for this: +16 as a basis, +0.05 points per hit-of-code (capped at +16), and -4 for exceeding 100 hits-of-code (258 >= 100). Please keep them coming while being mindful of contribution size. Your running score is +198; don't forget to check your Zerocracy account too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants