Skip to content

Commit 646fc22

Browse files
authored
Merge pull request #249 from h1alexbel/248
feat(#248): application-duality
2 parents 597e0ca + fe20439 commit 646fc22

File tree

10 files changed

+380
-0
lines changed

10 files changed

+380
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2016-2024 Objectionary.com
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included
15+
in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
-->
25+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="application-duality" version="2.0">
26+
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
27+
<xsl:import href="/org/eolang/funcs/escape.xsl"/>
28+
<xsl:output encoding="UTF-8" method="xml"/>
29+
<xsl:template match="/">
30+
<defects>
31+
<xsl:for-each select="//o[@base]">
32+
<xsl:if test="count(o) != count(o[@as]) and count(o) != count(o[not(@as)])">
33+
<defect>
34+
<xsl:attribute name="line">
35+
<xsl:value-of select="eo:lineno(@line)"/>
36+
</xsl:attribute>
37+
<xsl:attribute name="severity">
38+
<xsl:text>critical</xsl:text>
39+
</xsl:attribute>
40+
<xsl:text>The </xsl:text>
41+
<xsl:choose>
42+
<xsl:when test="@name">
43+
<xsl:text>object </xsl:text>
44+
<xsl:value-of select="eo:escape(@name)"/>
45+
</xsl:when>
46+
<xsl:otherwise>
47+
<xsl:text>anonymous object</xsl:text>
48+
</xsl:otherwise>
49+
</xsl:choose>
50+
<xsl:text> has duality in the application, which is prohibited</xsl:text>
51+
</defect>
52+
</xsl:if>
53+
</xsl:for-each>
54+
</defects>
55+
</xsl:template>
56+
</xsl:stylesheet>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Application Duality
2+
3+
In EO, it is not supported to have an application with and without binding at
4+
the same time, so it is prohibited in the [XMIR] too.
5+
6+
Incorrect:
7+
8+
```xml
9+
<o base="man">
10+
<o base="string" as="name"/>
11+
<o base="number"/>
12+
</o>
13+
```
14+
15+
Correct:
16+
17+
```xml
18+
<o base="man">
19+
<o base="string" as="name"/>
20+
<o base="number" as="age"/>
21+
</o>
22+
```
23+
24+
Or
25+
26+
```xml
27+
<o base="man">
28+
<o base="string"/>
29+
<o base="number"/>
30+
</o>
31+
```
32+
33+
[XMIR]: https://news.eolang.org/2022-11-25-xmir-guide.html
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=0]
27+
document: |
28+
<program>
29+
<objects>
30+
<o line="2" base="man">
31+
<o base="string" as="name"/>
32+
</o>
33+
</objects>
34+
</program>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=0]
27+
document: |
28+
<program>
29+
<objects>
30+
<o line="2" base="man">
31+
<o base="string"/>
32+
<o base="number"/>
33+
</o>
34+
</objects>
35+
</program>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=0]
27+
document: |
28+
<program>
29+
<objects>
30+
<o line="2" base="man">
31+
<o base="string" as="name"/>
32+
<o line="3" base="car" as="transport">
33+
<o base="string" as="model"/>
34+
<o base="number" as="hpw"/>
35+
</o>
36+
</o>
37+
</objects>
38+
</program>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=0]
27+
document: |
28+
<program>
29+
<objects>
30+
<o line="2" base="man">
31+
<o base="string" as="name"/>
32+
<o base="number" as="acc"/>
33+
</o>
34+
</objects>
35+
</program>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=1]
27+
- /defects/defect[@line='2']
28+
document: |
29+
<program>
30+
<objects>
31+
<o line="2" base="man">
32+
<o base="string" as="name"/>
33+
<o base="number"/>
34+
</o>
35+
</objects>
36+
</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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=2]
27+
- /defects/defect[@line='2']
28+
- /defects/defect[@line='3']
29+
document: |
30+
<program>
31+
<objects>
32+
<o line="2" base="man">
33+
<o base="string" as="name"/>
34+
<o line="3" base="car">
35+
<o base="string" as="model"/>
36+
<o base="number"/>
37+
</o>
38+
</o>
39+
</objects>
40+
</program>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=1]
27+
- /defects/defect[@line='2']
28+
document: |
29+
<program>
30+
<objects>
31+
<o line="2" base="man">
32+
<o base="string" as="name"/>
33+
<o base="number" as="acc"/>
34+
<o base="string"/>
35+
<o base="number"/>
36+
</o>
37+
</objects>
38+
</program>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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/critical/application-duality.xsl
25+
asserts:
26+
- /defects[count(defect[@severity='critical'])=0]
27+
document: |
28+
<program>
29+
<objects>
30+
<o line="2" name="man">
31+
<o base="string" as="name"/>
32+
<o base="number"/>
33+
</o>
34+
</objects>
35+
</program>

0 commit comments

Comments
 (0)