-
Notifications
You must be signed in to change notification settings - Fork 17
bug(#221): empty-object allows void attributes #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5e48ef4
bug(#221): allows void attributes
h1alexbel 1de6a4b
bug(#222): allows good objects
h1alexbel d7c3680
bug(#221): catches in snippet
h1alexbel 774b6db
bug(#221): no base
h1alexbel 5310849
Merge branch 'master' into 221
h1alexbel a13eefb
bug(#221): escaped
h1alexbel 7e7136c
bug(#221): simplified
h1alexbel 00a48f8
bug(#221): void off
h1alexbel c1ac7b6
bug(#221): 2025
h1alexbel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -27,27 +27,30 @@ SOFTWARE. | |
| <xsl:import href="/org/eolang/funcs/escape.xsl"/> | ||
| <xsl:output encoding="UTF-8" method="xml"/> | ||
| <xsl:template match="/"> | ||
| <xsl:variable name="void" select="//o[@base='∅']/@name"/> | ||
| <defects> | ||
| <xsl:for-each select="/program/objects//o[not(o)]"> | ||
| <xsl:element name="defect"> | ||
| <xsl:attribute name="line"> | ||
| <xsl:value-of select="eo:lineno(@line)"/> | ||
| </xsl:attribute> | ||
| <xsl:attribute name="severity"> | ||
| <xsl:text>warning</xsl:text> | ||
| </xsl:attribute> | ||
| <xsl:text>The </xsl:text> | ||
| <xsl:choose> | ||
| <xsl:when test="@name"> | ||
| <xsl:text>object </xsl:text> | ||
| <xsl:value-of select="eo:escape(@name)"/> | ||
| </xsl:when> | ||
| <xsl:otherwise> | ||
| <xsl:text>anonymous object</xsl:text> | ||
| </xsl:otherwise> | ||
| </xsl:choose> | ||
| <xsl:text> is empty. It doesn't have any attributes, neither void nor attached</xsl:text> | ||
| </xsl:element> | ||
| <xsl:for-each select="/program/objects//o[not(@base) and not(o) and not(@atom)]"> | ||
| <xsl:if test="not($void = @base)"> | ||
|
||
| <xsl:element name="defect"> | ||
| <xsl:attribute name="line"> | ||
| <xsl:value-of select="eo:lineno(@line)"/> | ||
| </xsl:attribute> | ||
| <xsl:attribute name="severity"> | ||
| <xsl:text>warning</xsl:text> | ||
| </xsl:attribute> | ||
| <xsl:text>The </xsl:text> | ||
| <xsl:choose> | ||
| <xsl:when test="@name"> | ||
| <xsl:text>object </xsl:text> | ||
| <xsl:value-of select="eo:escape(@name)"/> | ||
| </xsl:when> | ||
| <xsl:otherwise> | ||
| <xsl:text>anonymous object</xsl:text> | ||
| </xsl:otherwise> | ||
| </xsl:choose> | ||
| <xsl:text> is empty. It doesn't have any attributes, neither void nor attached</xsl:text> | ||
| </xsl:element> | ||
| </xsl:if> | ||
| </xsl:for-each> | ||
| </defects> | ||
| </xsl:template> | ||
|
|
||
41 changes: 41 additions & 0 deletions
41
...rg/eolang/lints/packs/empty-object/allows-good-objects-with-multiple-void-attributes.yaml
This file contains hidden or 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,41 @@ | ||
| # 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/errors/empty-object.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=0] | ||
| document: | | ||
| <program> | ||
| <objects> | ||
| <o line="2" name="main" pos="0"> | ||
| <o base="∅" line="2" name="x" pos="1"/> | ||
| <o base="∅" line="2" name="y" pos="1"/> | ||
| <o base=".print" line="3" name="@" pos="2"> | ||
| <o base="stdout" line="4" pos="4"> | ||
| <o base="string" line="4" pos="11">48-65-6C-6C-6F-21</o> | ||
| <o base="x" line="4" pos="20"/> | ||
| </o> | ||
| </o> | ||
| </o> | ||
| </objects> | ||
| </program> |
40 changes: 40 additions & 0 deletions
40
src/test/resources/org/eolang/lints/packs/empty-object/allows-good-objects.yaml
This file contains hidden or 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,40 @@ | ||
| # 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/errors/empty-object.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=0] | ||
| document: | | ||
| <program> | ||
| <objects> | ||
| <o line="2" name="main" pos="0"> | ||
| <o base="∅" line="2" name="x" pos="1"/> | ||
| <o base=".print" line="3" name="@" pos="2"> | ||
| <o base="stdout" line="4" pos="4"> | ||
| <o base="string" line="4" pos="11">48-65-6C-6C-6F-21</o> | ||
| <o base="x" line="4" pos="20"/> | ||
| </o> | ||
| </o> | ||
| </o> | ||
| </objects> | ||
| </program> |
34 changes: 34 additions & 0 deletions
34
src/test/resources/org/eolang/lints/packs/empty-object/allows-void-attributes.yaml
This file contains hidden or 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,34 @@ | ||
| # 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/errors/empty-object.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=0] | ||
| document: | | ||
| <program> | ||
| <objects> | ||
| <o line="2" name="main" pos="0"> | ||
| <o base="∅" line="2" name="x" pos="1"/> | ||
| </o> | ||
| </objects> | ||
| </program> |
41 changes: 41 additions & 0 deletions
41
.../org/eolang/lints/packs/empty-object/catches-empty-object-that-is-not-void-attribute.yaml
This file contains hidden or 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,41 @@ | ||
| # 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/errors/empty-object.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=1] | ||
| - /defects/defect[@line='4'] | ||
| document: | | ||
| <program> | ||
| <objects> | ||
| <o line="2" name="main" pos="0"> | ||
| <o base="∅" line="2" name="x" pos="1"/> | ||
| <o base=".print" line="3" name="@" pos="2"> | ||
| <o base="stdout" line="4" pos="4"> | ||
| <o base="string" line="4" pos="11">48-65-6C-6C-6F-21</o> | ||
| <o name="y" line="4" pos="20"/> | ||
| </o> | ||
| </o> | ||
| </o> | ||
| </objects> | ||
| </program> |
37 changes: 37 additions & 0 deletions
37
src/test/resources/org/eolang/lints/packs/empty-object/catches-empty-objects-in-snippet.yaml
This file contains hidden or 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,37 @@ | ||
| # 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/errors/empty-object.xsl | ||
| asserts: | ||
| - /defects[count(defect[@severity='warning'])=1] | ||
| - /defects/defect[@line='3'] | ||
| input: | | ||
| # Snippet with some empty objects. | ||
| [] > app | ||
| [] > a1 | ||
| if. > @ | ||
| true | ||
| [] | ||
| 2 > @ | ||
| 1 | ||
| [x] > a2 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel I don't really understand what is this comparison for? You've already checked that object does not have
@base='∅'in the line aboveUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxonfjvipon here, I check that
$void, which is a set of atom names don't contain@baseattribute of current object in the iteration.Consider following XMIR:
In this XMIR,
xobject referenced to the void attributex, declared at line 2. This check ensures that atom names ('x', 'y') containx. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel the original idea of such check was not to have abstract objects that does not have any inner objects, for example:
So the idea is simple - catch abstract object (which does not have
@baseattribute) that does not have inner<o>elements