Skip to content

Commit a1f7c47

Browse files
authored
Merge pull request #232 from h1alexbel/224
bug(#224): package understanding in object-does-not-match-filename
2 parents 1a3bdd5 + 4a9d4fb commit a1f7c47

File tree

8 files changed

+250
-2
lines changed

8 files changed

+250
-2
lines changed

src/main/resources/org/eolang/lints/names/object-does-not-match-filename.xsl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
SOFTWARE.
2424
-->
25-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" version="2.0" id="object-does-not-match-filename">
25+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:eo="https://www.eolang.org" version="2.0" id="object-does-not-match-filename">
2626
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
2727
<xsl:output encoding="UTF-8" method="xml"/>
28-
<xsl:variable name="filename" select="/program/@name"/>
28+
<xsl:variable name="package" select="/program/metas/meta[head='package']"/>
29+
<xsl:variable name="program" select="/program/@name"/>
30+
<xsl:variable name="filename" as="xs:string">
31+
<xsl:choose>
32+
<xsl:when test="$package/head != ''">
33+
<xsl:value-of select="substring-after($program, concat($package/tail, '.'))"/>
34+
</xsl:when>
35+
<xsl:otherwise>
36+
<xsl:value-of select="$program"/>
37+
</xsl:otherwise>
38+
</xsl:choose>
39+
</xsl:variable>
2940
<xsl:variable name="tested" select="/program/metas/meta[head='tests']"/>
3041
<xsl:template match="/">
3142
<defects>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2016-2024 Objectionary.com
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included
13+
# in all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
---
23+
sheets:
24+
- /org/eolang/lints/names/object-does-not-match-filename.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='warning'])=0]
27+
document: |
28+
<program name="foo.foo">
29+
<metas>
30+
<meta>
31+
<head>package</head>
32+
<tail>foo</tail>
33+
<part>foo</part>
34+
</meta>
35+
</metas>
36+
<objects>
37+
<o line="2" name="foo" pos="0"/>
38+
</objects>
39+
</program>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2016-2024 Objectionary.com
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included
13+
# in all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
---
23+
sheets:
24+
- /org/eolang/lints/names/object-does-not-match-filename.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='warning'])=0]
27+
document: |
28+
<program name="foo.bar.app">
29+
<metas>
30+
<meta>
31+
<head>package</head>
32+
<tail>foo.bar</tail>
33+
<part>foo.bar</part>
34+
</meta>
35+
</metas>
36+
<objects>
37+
<o line="2" name="app" pos="0"/>
38+
</objects>
39+
</program>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2016-2024 Objectionary.com
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included
13+
# in all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
---
23+
sheets:
24+
- /org/eolang/lints/names/object-does-not-match-filename.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='warning'])=0]
27+
document: |
28+
<program name="app.app">
29+
<metas>
30+
<meta>
31+
<head>package</head>
32+
<tail>app</tail>
33+
<part>app</part>
34+
</meta>
35+
</metas>
36+
<objects>
37+
<o line="2" name="app" pos="0"/>
38+
</objects>
39+
</program>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2016-2024 Objectionary.com
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included
13+
# in all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
---
23+
sheets:
24+
- /org/eolang/lints/names/object-does-not-match-filename.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='warning'])=1]
27+
- /defects/defect[@line='2']
28+
document: |
29+
<program name="org.foo">
30+
<metas>
31+
<meta>
32+
<head>package</head>
33+
<tail>org</tail>
34+
<part>org</part>
35+
</meta>
36+
</metas>
37+
<objects>
38+
<o line="2" name="bar" pos="0"/>
39+
</objects>
40+
</program>

src/test/resources/org/eolang/lints/packs/object-does-not-match-filename/catches-bad-name--with-children.yaml renamed to src/test/resources/org/eolang/lints/packs/object-does-not-match-filename/catches-bad-name-with-children.yaml

File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2016-2024 Objectionary.com
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included
13+
# in all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
---
23+
sheets:
24+
- /org/eolang/lints/names/object-does-not-match-filename.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='warning'])=1]
27+
- /defects/defect[@line='2']
28+
document: |
29+
<program name="app.app.app">
30+
<metas>
31+
<meta>
32+
<head>package</head>
33+
<tail>app</tail>
34+
<part>app</part>
35+
</meta>
36+
</metas>
37+
<objects>
38+
<o line="2" name="app" pos="0"/>
39+
</objects>
40+
</program>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2016-2024 Objectionary.com
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included
13+
# in all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
---
23+
sheets:
24+
- /org/eolang/lints/names/object-does-not-match-filename.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='warning'])=1]
27+
- /defects/defect[@line='2']
28+
document: |
29+
<program name="foo.bar.xyz">
30+
<metas>
31+
<meta>
32+
<head>package</head>
33+
<tail>foo.bar</tail>
34+
<part>foo.bar</part>
35+
</meta>
36+
</metas>
37+
<objects>
38+
<o line="2" name="app" pos="0"/>
39+
</objects>
40+
</program>

0 commit comments

Comments
 (0)