Skip to content
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

Merged
merged 3 commits into from
Feb 7, 2025

Conversation

h1alexbel
Copy link
Contributor

In this PR I've introduced void-attributes-not-higher-than-other lint, that issues defect with critical severity, if void attribute () is located lower than sibling non-void attributes.

closes #292

@h1alexbel
Copy link
Contributor Author

h1alexbel commented Feb 4, 2025

@maxonfjvipon check this one, please

<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="/">
<defects>
<xsl:apply-templates select="//o"/>
Copy link
Member

@maxonfjvipon maxonfjvipon Feb 5, 2025

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?

Copy link
Contributor Author

@h1alexbel h1alexbel Feb 5, 2025

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?

Copy link
Member

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

Copy link
Contributor Author

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

@h1alexbel
Copy link
Contributor Author

@maxonfjvipon updated. Take a look, please

@h1alexbel
Copy link
Contributor Author

@yegor256 take a look, please

@h1alexbel
Copy link
Contributor Author

@yegor256 reminder

1 similar comment
@h1alexbel
Copy link
Contributor Author

@yegor256 reminder

@yegor256 yegor256 merged commit 29b0da7 into objectionary:master Feb 7, 2025
16 checks passed
@yegor256
Copy link
Member

yegor256 commented Feb 7, 2025

@h1alexbel thanks!

@h1alexbel h1alexbel deleted the 292 branch February 7, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prohibit void attributes lower than other attributes
3 participants