diff --git a/src/main/resources/org/eolang/lints/comments/comment-is-too-wide.xsl b/src/main/resources/org/eolang/lints/comments/comment-is-too-wide.xsl new file mode 100644 index 00000000..7558faef --- /dev/null +++ b/src/main/resources/org/eolang/lints/comments/comment-is-too-wide.xsl @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + warning + + The comment line width is " + + ", while " + + " is max allowed + + + + + + + + + + + warning + + The comment width is " + + ", while " + + " is max allowed + + + + + + + + diff --git a/src/main/resources/org/eolang/motives/comments/comment-is-too-wide.md b/src/main/resources/org/eolang/motives/comments/comment-is-too-wide.md new file mode 100644 index 00000000..f92f33be --- /dev/null +++ b/src/main/resources/org/eolang/motives/comments/comment-is-too-wide.md @@ -0,0 +1,17 @@ +# Comment is too wide + +Each comment should be not wider than 80 characters. + +Incorrect: + +```eo +# This is a very long comment that contains more than eighty characters and should be flagged by the lint as too wide. +[] > foo +``` + +Correct: + +```eo +# This is a good comment. +[] > foo +``` diff --git a/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/allows-good-comment-width.yaml b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/allows-good-comment-width.yaml new file mode 100644 index 00000000..7417b95d --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/allows-good-comment-width.yaml @@ -0,0 +1,30 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016-2024 Objectionary.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +sheets: + - /org/eolang/lints/comments/comment-is-too-wide.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +input: | + # This comment is good. + [] > foo + 42 > @ diff --git a/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/allows-multiline-good-comment.yaml b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/allows-multiline-good-comment.yaml new file mode 100644 index 00000000..6106c403 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/allows-multiline-good-comment.yaml @@ -0,0 +1,33 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016-2024 Objectionary.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +sheets: + - /org/eolang/lints/comments/comment-is-too-wide.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +input: | + # This is good line. + # This is good line too. + # This is good line as well. + # We are here! + [] > foo + 52 > @ diff --git a/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/catches-multiline-wide-comment.yaml b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/catches-multiline-wide-comment.yaml new file mode 100644 index 00000000..f721e258 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/catches-multiline-wide-comment.yaml @@ -0,0 +1,32 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016-2024 Objectionary.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +sheets: + - /org/eolang/lints/comments/comment-is-too-wide.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='3'] +input: | + # This is good line. + # This is a very long line that contains more than eighty characters and should be flagged by the lint as too wide. + [] > foo + 42 > @ diff --git a/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/catches-too-wide-comment.yaml b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/catches-too-wide-comment.yaml new file mode 100644 index 00000000..6b8160c7 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/comment-is-too-wide/catches-too-wide-comment.yaml @@ -0,0 +1,31 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016-2024 Objectionary.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +sheets: + - /org/eolang/lints/comments/comment-is-too-wide.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='2'] +input: | + # This is a very long comment that contains more than eighty characters and should be flagged by the lint as too wide. + [] > foo + 42 > @