-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat(#292): void-attributes-not-higher-than-other
#309
Conversation
@maxonfjvipon check this one, please |
<xsl:output encoding="UTF-8" method="xml"/> | ||
<xsl:template match="/"> | ||
<defects> | ||
<xsl:apply-templates select="//o"/> |
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 just wonder why you don't cut processed objects here, in this place like: //o[@base='∅' and preceding-sibling::o[@base != '∅']
.
Instead you split it into two parts which makes you create two xsl:template
(I can be wrong here, but it seems to be not a good practice) and add extra xsl:if
block.
Does such approach improve something? Speed? Readability? Maintainability?
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 yes, it looks a bit more complicated than simple for-each
. Read this: https://www.onenaught.com/posts/23/xslt-tips-for-cleaner-code-and-better-performance (Avoid xsl:for-each; Use Template Match
section in particular). 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 ok, I got it about xs:for-each
, but I'm not suggest you to use it. I suggest to move the predicate from xsl:if
to template applying section at line 31:
<xsl:apply-templates select="//o[@base='∅' and preceding-sibling::o[@base != '∅']" mode="low-void"/>
...
<xsl:template match="o" mode="low-void">
<defect>
<xsl:attribute name="line">
<xsl:value-of select="eo:lineno(@line)"/>
</xsl:attribute>
<xsl:attribute name="severity">critical</xsl:attribute>
<xsl:text>Void attribute </xsl:text>
<xsl:value-of select="eo:escape(@name)"/>
<xsl:text> must be higher than any other non-void attribute</xsl:text>
</defect>
</xsl:template>
It seems more convenient to me because there's no more place where we potentially can put any other predicate. Are there any disadvantages of such appoach?
BTW: you forgot to add mode
to you template
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 looks good to me
@maxonfjvipon updated. Take a look, please |
@yegor256 take a look, please |
@yegor256 reminder |
1 similar comment
@yegor256 reminder |
@h1alexbel thanks! |
In this PR I've introduced
void-attributes-not-higher-than-other
lint, that issues defect withcritical
severity, if void attribute (∅
) is located lower than sibling non-void attributes.closes #292