forked from objectionary/lints
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/resources/org/eolang/lints/names/object-does-not-match-filename.xsl
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" id="object-does-not-match-filename"> | ||
<xsl:output encoding="UTF-8" method="xml"/> | ||
<xsl:variable name="filename" select="/program/@name"/> | ||
<xsl:variable name="tested" select="/program/metas/meta[head='tests']"/> | ||
<xsl:template match="/"> | ||
<defects> | ||
<xsl:apply-templates select="/program/objects/o[@name != $filename]" mode="confused-name"/> | ||
</defects> | ||
</xsl:template> | ||
<xsl:template match="o" mode="confused-name"> | ||
<xsl:if test="not($tested)"> | ||
<defect> | ||
<xsl:attribute name="line"> | ||
<xsl:value-of select="if (@line) then @line else '0'"/> | ||
</xsl:attribute> | ||
<xsl:attribute name="severity">warning</xsl:attribute> | ||
<xsl:text>Object "</xsl:text> | ||
<xsl:value-of select="@name"/> | ||
<xsl:text>" does not match with filename "</xsl:text> | ||
<xsl:value-of select="$filename"/> | ||
<xsl:text>"</xsl:text> | ||
</defect> | ||
</xsl:if> | ||
</xsl:template> | ||
</xsl:stylesheet> |
22 changes: 22 additions & 0 deletions
22
src/main/resources/org/eolang/motives/names/object-does-not-match-filename.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Object does not match Filename | ||
|
||
Every `.eo` file should not have different name than object, which may confuse | ||
the readers. | ||
|
||
Incorrect: | ||
|
||
`bar.eo`: | ||
|
||
```eo | ||
# Foo. | ||
[] > foo | ||
``` | ||
|
||
Correct: | ||
|
||
`foo.eo`: | ||
|
||
```eo | ||
# Foo. | ||
[] > foo | ||
``` |
This file contains 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
46 changes: 46 additions & 0 deletions
46
...org/eolang/lints/packs/object-does-not-match-filename/allows-good-name-with-children.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# 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/names/object-does-not-match-filename.xsl | ||
asserts: | ||
- /defects[count(defect[@severity='warning'])=0] | ||
document: | | ||
<program name="top"> | ||
<objects> | ||
<o line="2" name="top" pos="0"> | ||
<o base="a" line="3" name="x" pos="2"> | ||
<o base="b" line="4" pos="4"> | ||
<o base="c" line="5" pos="6"> | ||
<o base="d" line="6" pos="8"> | ||
<o base="e" line="7" pos="10"> | ||
<o base="f" line="8" pos="12"> | ||
<o base="g" line="9" pos="14"/> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</objects> | ||
</program> |
32 changes: 32 additions & 0 deletions
32
...st/resources/org/eolang/lints/packs/object-does-not-match-filename/allows-good-names.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/names/object-does-not-match-filename.xsl | ||
asserts: | ||
- /defects[count(defect[@severity='warning'])=0] | ||
document: | | ||
<program name="foo"> | ||
<objects> | ||
<o line="2" name="foo" pos="0"/> | ||
</objects> | ||
</program> |
38 changes: 38 additions & 0 deletions
38
...es/org/eolang/lints/packs/object-does-not-match-filename/allows-other-names-in-tests.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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/names/object-does-not-match-filename.xsl | ||
asserts: | ||
- /defects[count(defect[@severity='warning'])=0] | ||
document: | | ||
<program name="foo-tests"> | ||
<metas> | ||
<meta line="1"> | ||
<head>tests</head> | ||
<tail/> | ||
</meta> | ||
</metas> | ||
<objects> | ||
<o line="4" name="foo" pos="0"/> | ||
</objects> | ||
</program> |
47 changes: 47 additions & 0 deletions
47
...rg/eolang/lints/packs/object-does-not-match-filename/catches-bad-name--with-children.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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/names/object-does-not-match-filename.xsl | ||
asserts: | ||
- /defects[count(defect[@severity='warning'])=1] | ||
- /defects/defect[@line='2'] | ||
document: | | ||
<program name="foo"> | ||
<objects> | ||
<o line="2" name="top" pos="0"> | ||
<o base="a" line="3" name="x" pos="2"> | ||
<o base="b" line="4" pos="4"> | ||
<o base="c" line="5" pos="6"> | ||
<o base="d" line="6" pos="8"> | ||
<o base="e" line="7" pos="10"> | ||
<o base="f" line="8" pos="12"> | ||
<o base="g" line="9" pos="14"/> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</o> | ||
</objects> | ||
</program> |
33 changes: 33 additions & 0 deletions
33
...st/resources/org/eolang/lints/packs/object-does-not-match-filename/catches-bad-names.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/names/object-does-not-match-filename.xsl | ||
asserts: | ||
- /defects[count(defect[@severity='warning'])=1] | ||
- /defects/defect[@line='2'] | ||
document: | | ||
<program name="bar"> | ||
<objects> | ||
<o line="2" name="foo" pos="0"/> | ||
</objects> | ||
</program> |