fix(#950): keep line-zero defects with line-specific unlint - #1225
Closed
VasilevNStas wants to merge 1 commit into
Closed
fix(#950): keep line-zero defects with line-specific unlint#1225VasilevNStas wants to merge 1 commit into
VasilevNStas wants to merge 1 commit into
Conversation
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. |
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). |
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.
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.