Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/main/resources/org/eolang/funcs/special-name.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<xsl:import href="/org/eolang/parser/_funcs.xsl"/>
<xsl:function name="eo:special" as="xs:boolean">
<xsl:param name="name"/>
<xsl:sequence select="$name = '&#x3C6;' or $name = $eo:lambda or contains($name, $eo:cactoos)"/>
<xsl:sequence select="$name = '&#x3C6;' or $name = $eo:lambda or $name = $eo:xi or contains($name, $eo:cactoos)"/>
</xsl:function>
</xsl:stylesheet>
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-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="invalid-name-notation" version="2.0">
<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:import href="/org/eolang/funcs/test-name.xsl"/>
<xsl:import href="/org/eolang/funcs/escape.xsl"/>
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="/">
<defects>
<xsl:for-each select="//o[@name and not(eo:special(@name)) and not(eo:test-name(@name)) and not(matches(@name, '^[a-z]+(-[a-z]+)*$'))]">
<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="eo:escape(@name)"/>
<xsl:text> must match the regular expression [a-z]+(-[a-z]+)*</xsl:text>
</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 name of any object must match the regular expression `[a-z]+(-[a-z]+)*`.
Basically, it must follow kebab-case notation, using only Latin letters.
No digits, no underscores, no uppercase characters.

Incorrect:

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

Correct:

```eo
# App.
[] > main-app
foo > x
bar > y
```
2 changes: 1 addition & 1 deletion src/test/resources/org/eolang/lints/canonical.eo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
x.put 2
while
x.as-number.lt 6 > [i1] >>
x.as-number.lt 6 > [i] >>
[i] >>
seq > @
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/names/invalid-name-notation.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
ignore-schema: true
document: |
<object author="tests">
<o line="1" name="main-app" pos="0">
<o base="Q.foo" line="2" name="x" pos="2"/>
<o base="Q.bar" line="3" name="y" pos="2"/>
</o>
</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
---
sheets:
- /org/eolang/lints/names/invalid-name-notation.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
ignore-schema: true
document: |
<object author="tests">
<o line="1" name="app" pos="0">
<o base="Q.x" line="2" name="f" pos="2">
<o line="3" name="a🌵3-5" pos="4"/>
<o line="4" name="φ" pos="4">
<o base="Q.q" line="5" name="ξ" pos="6"/>
</o>
</o>
</o>
</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
# SPDX-License-Identifier: MIT
# yamllint disable rule:line-length
---
sheets:
- /org/eolang/lints/names/invalid-name-notation.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
ignore-schema: true
document: |
<object author="tests">
<o line="1" name="foo" pos="0">
<o base="Q.number" line="2" name="-on-bytes-of-wrong-size-as-i16" pos="2"/>
</o>
</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: Copyright (c) 2016-2026 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']
ignore-schema: true
document: |
<object author="tests">
<o line="1" name="main" pos="0">
<o base="Q.foo" line="2" name="x1" pos="2"/>
<o base="Q.foo" line="3" name="xApp" pos="2"/>
<o base="Q.foo" line="4" name="x_snake" pos="2"/>
</o>
</object>
Loading