fix(#950): keep line-zero defects with line-specific unlint - #1232
fix(#950): keep line-zero defects with line-specific unlint#1232VasilevNStas wants to merge 1 commit into
Conversation
|
@yegor256 @volodya-lombrozo please review |
volodya-lombrozo
left a comment
There was a problem hiding this comment.
@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
left a comment
There was a problem hiding this comment.
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.
3421165 to
31a47e6
Compare
|
@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. |
|
Understood, thank you for the clear guidance. The PR came from a code audit where the line- |
3421165 to
96898a7
Compare
96898a7 to
3f27062
Compare
Fixes #950.
Problem
In
LtUnlint.defects()the loop that re-adds non-suppressed defects uses the guardline != 0 && defect.line() == line. When a lint produces a defect at line 0 (e.g.mandatory-packagereports at line 0 when the whole+packagemeta is absent) and the EO program also contains a line-specific+unlint mandatory-package:5, the defect at line 0 is silently discarded:globalis set, line 0 stays inproblematicbut is skipped byline != 0, and the fallbackif (!added.get() && !global)is also skipped becauseglobalis true.Solution
Drop the
line != 0guard in the re-add loop and comparedefect.line() == lineonly. Line 0 is an intentional production case (lineno.xslandempty-object.xslhandle 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 testkeepsLineZeroDefectWithLineSpecificUnlint(failed before the fix).Tests
LtUnlintTest— 12 tests green (incl. new one).LtByXslTest,SourceTest,PkMonoTest,MonoLintsTest,LtUnlintNonExistingDefectTest— 443 tests green aftermvn clean.mvn -Pqulice install— clean.