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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
* SPDX-License-Identifier: MIT
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" version="2.0" id="invalid-name-notation">
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
<xsl:import href="/org/eolang/funcs/defect-context.xsl"/>
<xsl:import href="/org/eolang/funcs/special-name.xsl"/>
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:variable name="pattern" select="'^[a-z]+(-[a-z]+)*$'"/>
<xsl:template match="/">
<defects>
<xsl:for-each select="//o[@name and not(eo:special(@name)) and not(matches(@name, $pattern))]">
<defect>
<xsl:variable name="line" select="eo:lineno(@line)"/>
<xsl:attribute name="line">
<xsl:value-of select="$line"/>
</xsl:attribute>
<xsl:if test="$line = '0'">
<xsl:attribute name="context">
<xsl:value-of select="eo:defect-context(.)"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="severity">warning</xsl:attribute>
<xsl:text>Object name "</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>" doesn’t match the regular expression </xsl:text>
<xsl:value-of select="$pattern"/>
</defect>
</xsl:for-each>
</defects>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Invalid name notation

The object name must match the regular expression `[a-z]+(-[a-z]+)*`.
Basically, it should follow kebab-case style,
but using only Latin letters - no digits or other characters.

Incorrect:

```eo
# App.
[] > mainApp
foo > x1
bar > y_
```

Correct:

```eo
# App.
[] > main-app
foo > x
bar > y
```
4 changes: 2 additions & 2 deletions src/test/resources/org/eolang/lints/canonical.eo
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*
x.put 2
while
x.as-number.lt 6 > [i1] >>
[i] >>
x.as-number.lt 6 > [i] >>
[j] >>
seq > @
*
QQ.io.stdout
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/names/invalid-name-notation.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
input: |
# App.
[] > main-app
foo > x
bar > y
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/names/invalid-name-notation.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
input: |
# App.
[] > app
x > f
[] >>
foo > @
[] > baz ?
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/names/invalid-name-notation.xsl
asserts:
- /defects[count(defect[@severity='warning'])=3]
- /defects/defect[@line='2']
- /defects/defect[@line='3']
- /defects/defect[@line='4']
input: |
# App.
[] > mainApp
foo > x1
bar > y_
Loading