Skip to content

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

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

fix(#950): keep line-zero defects with line-specific unlint#1232
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.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 @volodya-lombrozo please review

@volodya-lombrozo volodya-lombrozo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VasilevNStas To be honest, I don't clearly understand the purpose of these changed. Can u provide actual and expected behaviour in the issue description please? Also, please, pay attention that the issue you are trying to solved weren't accepted by maintainers.

@VasilevNStas VasilevNStas left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replying to the review summary: I added the actual/expected explanation in the thread on unlint-mandatory-package-line.eo. In short: before this change, +unlint <name>:0 could never suppress the line-0 defect (e.g. from mandatory-package), because of the line != 0 guard; the fix removes that guard so line 0 behaves like any other line. This was found during a code audit, not requested in the ticket. I understand the ticket was not formally accepted — if the line != 0 guard is intentional, please say so and I will close the PR.

@VasilevNStas
VasilevNStas force-pushed the fix/issue-950-line-zero-defect branch from 3421165 to 31a47e6 Compare August 13, 2026 06:58
@yegor256

Copy link
Copy Markdown
Member

@VasilevNStas my suggestion: don't try to fix issues that are not yet labeled as "bugs" or "enhancement". You mostly waste your and our time by doing this.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

Understood, thank you for the clear guidance. The PR came from a code audit where the line-0 suppression looked like an inconsistency, not from a labeled issue. I will keep the PR open as-is for reference, but going forward I will only work on issues that are explicitly labeled as bug or enhancement, and won't spend time on unlabeled ones. Appreciate the directness.

@VasilevNStas
VasilevNStas force-pushed the fix/issue-950-line-zero-defect branch 3 times, most recently from 3421165 to 96898a7 Compare August 15, 2026 11:05
@VasilevNStas
VasilevNStas force-pushed the fix/issue-950-line-zero-defect branch from 96898a7 to 3f27062 Compare August 15, 2026 12:08
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

3 participants