Skip to content
Merged
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
14 changes: 12 additions & 2 deletions src/main/resources/org/eolang/lints/names/compound-name.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@
<xsl:import href="/org/eolang/funcs/special-name.xsl"/>
<xsl:import href="/org/eolang/funcs/escape.xsl"/>
<xsl:output encoding="UTF-8" method="xml"/>
<!--Since developers might decide not to use kebab-case, its better to catch all such cases.-->
<!--Since developers might decide not to use kebab-case, it's better to catch all such cases.-->
<xsl:function name="eo:compound" as="xs:boolean">
<xsl:param name="name"/>
<xsl:sequence select="contains($name, '-') or contains($name, '_') or matches($name, '[A-Z]')"/>
</xsl:function>
<!--
These prefixes/suffixes are idiomatic in EO standard library:
- 'as-' for type conversions (as-bytes, as-i64, as-number, etc.)
- 'is-' for boolean predicates (is-empty, is-nan, is-finite, etc.)
- '-of' for extracting parts (slice-of, value-of, length-of, etc.)
-->
<xsl:function name="eo:idiomatic" as="xs:boolean">
<xsl:param name="name"/>
<xsl:sequence select="starts-with($name, 'as-') or starts-with($name, 'is-') or ends-with($name, '-of')"/>
</xsl:function>
<xsl:template match="/">
<defects>
<xsl:for-each select="//o[@base and @name and not(eo:special(@name)) and eo:compound(@name)]">
<xsl:for-each select="//o[@base and @name and not(eo:special(@name)) and eo:compound(@name) and not(eo:idiomatic(@name))]">
Comment on lines +23 to +29
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exemption is currently overly broad: any compound name starting with as- or is- bypasses the lint (e.g., as-very-long-compound-name), which undermines the rule and makes it easy to evade. Consider tightening eo:idiomatic($name) to only allow the intended idiomatic form (e.g., a single hyphen with a simple suffix via a regex like ^(as|is)-[a-z0-9]+$, or another clearly bounded pattern consistent with EO stdlib naming).

Copilot uses AI. Check for mistakes.
<defect>
<xsl:variable name="line" select="eo:lineno(@line)"/>
<xsl:attribute name="line">
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/org/eolang/motives/names/compound-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ Correct:
parse > records
read file
```

There are exceptions for idiomatic prefixes and suffixes.
The `as-` prefix is for type conversions: `as-bytes`, `as-i64`, `as-number`.
The `is-` prefix is for predicates: `is-empty`, `is-nan`, `is-finite`.
The `-of` suffix is for extracting parts: `slice-of`, `value-of`, `length-of`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/names/compound-name.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion only guarantees there are no warning defects; the test could still pass if the lint emits defects with a different severity (e.g., error). If the intent is to ensure no defects at all for these names, consider asserting count(defect)=0 (or explicitly covering all severities expected in this lint pack) to make the regression test more robust.

Suggested change
- /defects[count(defect[@severity='warning'])=0]
- /defects[count(defect)=0]

Copilot uses AI. Check for mistakes.
input: |
# No comments.
[] > main
x.as-bytes > as-bytes
y.as-i64 > as-i64
z.is-empty > is-empty
w.is-nan > is-nan
a.slice-of > slice-of
b.value-of > value-of
Loading