From e97c69a9dbf32797b5e1c676d88e2fcd265cd835 Mon Sep 17 00:00:00 2001 From: Travis Gosselin Date: Tue, 20 Aug 2024 09:50:07 -0400 Subject: [PATCH] fix: Relax the aggressive of the id vs identifier detection (#89) This pull request fixes an issue where the detection of "id" vs "identifier" was too aggressive. The fix makes the detection more specific. --- rulesets/src/naming.ruleset.yml | 2 +- ...s-mandate-abbreviations-identifier.test.js | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/rulesets/src/naming.ruleset.yml b/rulesets/src/naming.ruleset.yml index 730cc59..fa40a73 100644 --- a/rulesets/src/naming.ruleset.yml +++ b/rulesets/src/naming.ruleset.yml @@ -112,7 +112,7 @@ rules: then: function: pattern functionOptions: - notMatch: "(^identifier([A-Z]|$)|.*Identifier([A-Z]|$))" + notMatch: "^identifier$" sps-mandate-abbreviations-organization: description: Use abbreviations instead of long form names, i.e. organization SHOULD BE org. diff --git a/rulesets/test/naming/sps-mandate-abbreviations-identifier.test.js b/rulesets/test/naming/sps-mandate-abbreviations-identifier.test.js index 3b94557..7bff111 100644 --- a/rulesets/test/naming/sps-mandate-abbreviations-identifier.test.js +++ b/rulesets/test/naming/sps-mandate-abbreviations-identifier.test.js @@ -59,7 +59,7 @@ describe("sps-mandate-abbreviations-identifier", () => { await spectral.validateFailure(spec, ruleName, "Warning", 1); }); - test("identifier should warn when it is a word present in the field name", async () => { + test("identifier should not warn when it is a word present in the field name prefix", async () => { const spec = ` openapi: 3.0.1 paths: {} @@ -70,9 +70,24 @@ describe("sps-mandate-abbreviations-identifier", () => { properties: identifierNumber: type: number - NumberIdentifier `; - await spectral.validateFailure(spec, ruleName, "Warning", 1); + await spectral.validateSuccess(spec, ruleName); + }); + + test("identifier should not warn when it is a word present in the field name suffix", async () => { + const spec = ` + openapi: 3.0.1 + paths: {} + components: + schemas: + User: + type: object + properties: + externalIdentifier: + type: number + `; + + await spectral.validateSuccess(spec, ruleName); }); });