Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/main/resources/org/eolang/lints/misc/unused-void-attr.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
* SPDX-License-Identifier: MIT
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="unused-void-attr" version="2.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="unused-void-attr" version="2.0">
<xsl:import href="/org/eolang/parser/_funcs.xsl"/>
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
<xsl:import href="/org/eolang/funcs/escape.xsl"/>
Expand All @@ -14,7 +14,18 @@
<xsl:for-each select="//o[@base='∅']">
<xsl:variable name="attr" select="@name"/>
<xsl:variable name="formation" select=".."/>
<xsl:if test="not($attr='φ') and not(eo:atom($formation)) and not($formation//o[contains(@base, concat('ξ.', $attr))]/ancestor::o[eo:abstract(.)][1][generate-id()=$formation/generate-id()]) and not($formation//o[eo:atom(.)])">
<xsl:variable name="pattern" select="concat('^ξ(\.ρ)*\.', $attr, '(\..*)?$')"/>
<xsl:variable name="usages" as="element()*">
<xsl:for-each select="$formation//o[matches(@base, $pattern)]">
<xsl:variable name="rhos" select="replace(@base, concat('^ξ((\.ρ)*)\.', $attr, '.*$'), '$1')"/>
<xsl:variable name="hops" select="string-length($rhos) - string-length(translate($rhos, 'ρ', ''))" as="xs:integer"/>
<xsl:variable name="anchor" select="ancestor::o[eo:abstract(.)][position() = $hops + 1]"/>
<xsl:if test="exists($anchor) and generate-id($anchor) = generate-id($formation)">
<xsl:sequence select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test="not($attr='φ') and not(eo:atom($formation)) and empty($usages) and not($formation//o[eo:atom(.)])">
<xsl:element name="defect">
<xsl:variable name="line" select="eo:lineno(@line)"/>
<xsl:attribute name="line">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
sheets:
- /org/eolang/lints/misc/unused-void-attr.xsl
asserts:
- /defects[count(defect[@severity='warning'])=1]
- /defects/defect[@line='2']
- /defects[count(defect[@severity='warning'])=0]
input: |
# Foo
[x] > foo
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
# Regression test for objectionary/lints#637.
# The void attribute "widths" of "tabular" is referenced from inside the
# nested "[i] > inner" formation as "widths.at i", which the parser turns
# into "ξ.ρ.widths.at". The lint must recognise this rho-walking reference
# as a real usage and not flag "widths" as unused.
sheets:
- /org/eolang/lints/misc/unused-void-attr.xsl
asserts:
- /defects[count(defect[contains(., '"widths"')])=0]
input: |
# Foo.
[widths] > tabular
[i] > inner
widths.at i > @
Loading