Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 11 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,23 @@
<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 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.)
-->
<xsl:function name="eo:idiomatic" as="xs:boolean">
<xsl:param name="name"/>
<xsl:sequence select="starts-with($name, 'as-') or starts-with($name, 'is-')"/>
</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
4 changes: 4 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 @@ -4,6 +4,10 @@ All objects that are not formations must have single-word names.
Compound names indicate that the program context is too large
and needs to be decomposed.

There are two exceptions for idiomatic prefixes used in EO standard library:
the `as-` prefix for type conversions (such as `as-bytes`, `as-i64`, `as-number`)
and the `is-` prefix for boolean predicates (such as `is-empty`, `is-nan`, `is-finite`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚫 [vale] reported by reviewdog 🐶
[Vale.Spelling] Did you really mean 'boolean'?


Incorrect:

```eo
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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]
input: |
# No comments.
[] > main
x.as-bytes > as-bytes
y.as-i64 > as-i64
z.is-empty > is-empty
w.is-nan > is-nan
Loading