diff --git a/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl b/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl new file mode 100644 index 000000000..a6eae13f6 --- /dev/null +++ b/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + warning + Object name " + + " doesn’t match the regular expression + + + + + + diff --git a/src/main/resources/org/eolang/motives/names/invalid-name-notation.md b/src/main/resources/org/eolang/motives/names/invalid-name-notation.md new file mode 100644 index 000000000..c9006e952 --- /dev/null +++ b/src/main/resources/org/eolang/motives/names/invalid-name-notation.md @@ -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 +``` diff --git a/src/test/resources/org/eolang/lints/canonical.eo b/src/test/resources/org/eolang/lints/canonical.eo index 098db4502..01edd2b82 100644 --- a/src/test/resources/org/eolang/lints/canonical.eo +++ b/src/test/resources/org/eolang/lints/canonical.eo @@ -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 diff --git a/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-good-names.yaml b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-good-names.yaml new file mode 100644 index 000000000..e82abc5f0 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-good-names.yaml @@ -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 diff --git a/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-special-names.yaml b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-special-names.yaml new file mode 100644 index 000000000..bcab23373 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-special-names.yaml @@ -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 ? diff --git a/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-invalid-names.yaml b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-invalid-names.yaml new file mode 100644 index 000000000..f09196ec6 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-invalid-names.yaml @@ -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_