diff --git a/src/main/resources/org/eolang/lints/tests/test-with-comment.xsl b/src/main/resources/org/eolang/lints/tests/test-with-comment.xsl new file mode 100644 index 000000000..5790304fd --- /dev/null +++ b/src/main/resources/org/eolang/lints/tests/test-with-comment.xsl @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + warning + The test object + + has a comment, which duplicates its name. Make the name self-explanatory and remove the comment + + + + + diff --git a/src/main/resources/org/eolang/motives/tests/test-with-comment.md b/src/main/resources/org/eolang/motives/tests/test-with-comment.md new file mode 100644 index 000000000..05b337c88 --- /dev/null +++ b/src/main/resources/org/eolang/motives/tests/test-with-comment.md @@ -0,0 +1,24 @@ +# Test with comment + +A test object must not have a comment before it. A comment usually just +duplicates the test name: if the test is named `checks-the-app`, a comment +like "This test checks the app" adds nothing. Instead of documenting a +test, make its name short and self-explanatory. + +Incorrect: + +```eo +# This test checks the app. + +[] +> checks-the-app + 42 > @ +``` + +Correct: + +```eo +[] +> checks-the-app + 42 > @ +``` + +The name says it all; the comment is redundant. diff --git a/src/test/resources/org/eolang/lints/packs/single/test-with-comment/allows-test-without-comment.yaml b/src/test/resources/org/eolang/lints/packs/single/test-with-comment/allows-test-without-comment.yaml new file mode 100644 index 000000000..7b4572752 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-with-comment/allows-test-without-comment.yaml @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-with-comment.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +input: | + [] > foo + + [] +> checks-the-app + 42 > @ diff --git a/src/test/resources/org/eolang/lints/packs/single/test-with-comment/catches-test-with-comment.yaml b/src/test/resources/org/eolang/lints/packs/single/test-with-comment/catches-test-with-comment.yaml new file mode 100644 index 000000000..f3e35eecb --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/test-with-comment/catches-test-with-comment.yaml @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/tests/test-with-comment.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] +input: | + # This test checks the app. + + [] +> checks-the-app + 42 > @