Skip to content

fix(#950): keep line-zero defects with line-specific unlint - #1225

Closed
VasilevNStas wants to merge 1 commit into
objectionary:masterfrom
VasilevNStas:fix/issue-950-line-zero-defect
Closed

fix(#950): keep line-zero defects with line-specific unlint#1225
VasilevNStas wants to merge 1 commit into
objectionary:masterfrom
VasilevNStas:fix/issue-950-line-zero-defect

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

Fixes #950.

Problem

In LtUnlint.defects() the loop that re-adds non-suppressed defects uses the guard line != 0 && defect.line() == line. When a lint produces a defect at line 0 (e.g. mandatory-package reports at line 0 when the whole +package meta is absent) and the EO program also contains a line-specific +unlint mandatory-package:5, the defect at line 0 is silently discarded: global is set, line 0 stays in problematic but is skipped by line != 0, and the fallback if (!added.get() && !global) is also skipped because global is true.

Solution

Drop the line != 0 guard in the re-add loop and compare defect.line() == line only. Line 0 is an intentional production case (lineno.xsl and empty-object.xsl handle it explicitly) and is only meant to be suppressed by a global +unlint lint-name, never by a line-specific +unlint lint-name:N.

Changes

  • src/main/java/org/eolang/lints/LtUnlint.java — re-add defects on line 0 when their line stays problematic.
  • src/test/resources/org/eolang/lints/unlint-mandatory-package-line.eo — new fixture: no +package, +unlint mandatory-package:5.
  • src/test/java/org/eolang/lints/LtUnlintTest.java — new test keepsLineZeroDefectWithLineSpecificUnlint (failed before the fix).

Tests

  • LtUnlintTest — 12 tests green (incl. new one).
  • Regression LtByXslTest, SourceTest, PkMonoTest, MonoLintsTest, LtUnlintNonExistingDefectTest — 443 tests green after mvn clean.
  • mvn -Pqulice install — clean.

@volodya-lombrozo

Copy link
Copy Markdown
Member

Thanks for working on this! Unfortunately the commits aren't GPG/SSH-signed, which rultor needs to merge. GitHub's signing guide: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits. Closing for now — happy to see this reopened once signed.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@volodya-lombrozo, fixed — commits are now SSH-signed (verified by GitHub). Since the closed PR can't be reopened after a force-push, I've recreated it as #1232 (same change, signed commits).

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.

LtUnlint silently drops defects at line 0 when a line-specific +unlint meta is present

2 participants