From 4742bda9db2a18a9b4d59fe1c3efaf0d73764b00 Mon Sep 17 00:00:00 2001 From: Marat-Tim Date: Fri, 9 May 2025 12:52:51 +0300 Subject: [PATCH 1/4] feat(#566): check name match kebab-case --- .../lints/names/invalid-name-notation.xsl | 33 +++++++++++++++++++ .../motives/names/invalid-name-notation.md | 23 +++++++++++++ .../resources/org/eolang/lints/canonical.eo | 4 +-- .../allows-good-names.yaml | 12 +++++++ .../catches-invalid-names.yaml | 15 +++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl create mode 100644 src/main/resources/org/eolang/motives/names/invalid-name-notation.md create mode 100644 src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-good-names.yaml create mode 100644 src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-invalid-names.yaml 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..b87134e04 --- /dev/null +++ b/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + 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 523c950db..47b1aa6ae 100644 --- a/src/test/resources/org/eolang/lints/canonical.eo +++ b/src/test/resources/org/eolang/lints/canonical.eo @@ -15,8 +15,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/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_ From 37a5d500b4a85c9e8dca7e69354bcd4df8802fd5 Mon Sep 17 00:00:00 2001 From: Marat-Tim Date: Fri, 9 May 2025 13:43:12 +0300 Subject: [PATCH 2/4] feat(#566): ignore special names --- .../resources/org/eolang/funcs/special-name.xsl | 13 +++++++++++++ .../eolang/lints/names/invalid-name-notation.xsl | 5 +++-- .../invalid-name-notation/allows-special-names.yaml | 12 ++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/org/eolang/funcs/special-name.xsl create mode 100644 src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-special-names.yaml diff --git a/src/main/resources/org/eolang/funcs/special-name.xsl b/src/main/resources/org/eolang/funcs/special-name.xsl new file mode 100644 index 000000000..28cb59e5d --- /dev/null +++ b/src/main/resources/org/eolang/funcs/special-name.xsl @@ -0,0 +1,13 @@ + + + + + + + + + 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 index b87134e04..a6eae13f6 100644 --- a/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl +++ b/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl @@ -3,14 +3,15 @@ * SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com * SPDX-License-Identifier: MIT --> - + + - + 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..641d5c3ae --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-special-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. + [] >> + foo > @ + bar ? From 4621f49f6ee63a77ac18e4cde3e93f25cf66fbd2 Mon Sep 17 00:00:00 2001 From: Marat-Tim Date: Fri, 9 May 2025 13:53:10 +0300 Subject: [PATCH 3/4] feat(#566): fix formatting --- .../resources/org/eolang/funcs/special-name.xsl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/resources/org/eolang/funcs/special-name.xsl b/src/main/resources/org/eolang/funcs/special-name.xsl index 28cb59e5d..98d1eaf28 100644 --- a/src/main/resources/org/eolang/funcs/special-name.xsl +++ b/src/main/resources/org/eolang/funcs/special-name.xsl @@ -3,11 +3,10 @@ ~ SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com ~ SPDX-License-Identifier: MIT --> - - - - - - + + + + + + From df45486f3a69122eb07d398f65565dd79d2db2b0 Mon Sep 17 00:00:00 2001 From: Marat-Tim Date: Fri, 9 May 2025 14:07:30 +0300 Subject: [PATCH 4/4] feat(#566): fix special names test --- .../single/invalid-name-notation/allows-special-names.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 index 641d5c3ae..bcab23373 100644 --- 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 @@ -7,6 +7,8 @@ asserts: - /defects[count(defect[@severity='warning'])=0] input: | # App. - [] >> + [] > app + x > f + [] >> foo > @ - bar ? + [] > baz ?