diff --git a/src/main/java/org/eolang/lints/LtUnlint.java b/src/main/java/org/eolang/lints/LtUnlint.java index 7c67261f6..34eccf4c3 100644 --- a/src/main/java/org/eolang/lints/LtUnlint.java +++ b/src/main/java/org/eolang/lints/LtUnlint.java @@ -74,7 +74,7 @@ public Collection defects(final XML xmir) throws IOException { problematic.forEach( line -> found.forEach( defect -> { - if (line != 0 && defect.line() == line) { + if (defect.line() == line) { defects.add(defect); added.set(true); } diff --git a/src/test/java/org/eolang/lints/LtUnlintTest.java b/src/test/java/org/eolang/lints/LtUnlintTest.java index c1f79c451..9c0b6a10b 100644 --- a/src/test/java/org/eolang/lints/LtUnlintTest.java +++ b/src/test/java/org/eolang/lints/LtUnlintTest.java @@ -151,4 +151,17 @@ void catchesAllOutOfRangeDefects() throws IOException { Matchers.iterableWithSize(1) ); } + + @Test + void keepsLineZeroDefectWithLineSpecificUnlint() throws IOException { + MatcherAssert.assertThat( + "A line-0 defect must not be silently dropped by a line-specific unlint", + new LtUnlint(new LtByXsl("metas/mandatory-package")).defects( + new EoProgram( + "org/eolang/lints/unlint-mandatory-package-line.eo" + ).parse() + ), + Matchers.iterableWithSize(1) + ); + } } diff --git a/src/test/resources/org/eolang/lints/unlint-mandatory-package-line.eo b/src/test/resources/org/eolang/lints/unlint-mandatory-package-line.eo new file mode 100644 index 000000000..eb812a964 --- /dev/null +++ b/src/test/resources/org/eolang/lints/unlint-mandatory-package-line.eo @@ -0,0 +1,11 @@ +# Missing package, but it should be reported anyway. + ++architect yegor256@gmail.com ++home https://www.eolang.org ++version 0.0.0 ++spdx SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com ++spdx SPDX-License-Identifier: MIT ++unlint mandatory-package:5 + +# Boo. +[] > foo \ No newline at end of file