Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Dec 23, 2024
2 parents bc249fe + 70a4030 commit fde0087
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 0 deletions.
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>
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
```
1 change: 1 addition & 0 deletions src/test/java/org/eolang/lints/ProgramTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void returnsEmptyListOfDefects() throws IOException {
"no defects found since the code is clean",
new Program(
new EoSyntax(
"foo",
new InputOf(
String.join(
"\n",
Expand Down
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>
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>
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>
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>
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>

0 comments on commit fde0087

Please sign in to comment.