diff --git a/rules/S6958/javascript/metadata.json b/rules/S6958/javascript/metadata.json new file mode 100644 index 00000000000..2c63c085104 --- /dev/null +++ b/rules/S6958/javascript/metadata.json @@ -0,0 +1,2 @@ +{ +} diff --git a/rules/S6958/javascript/rule.adoc b/rules/S6958/javascript/rule.adoc new file mode 100644 index 00000000000..500bfc7282f --- /dev/null +++ b/rules/S6958/javascript/rule.adoc @@ -0,0 +1,24 @@ +== Why is this an issue? + +Calling a literal throws a TypeError, and is likely the result of an unintentional error in the code. + +This rule raises an issue when an attempt is made to use a literal as a function. + + +[source,js] +---- +true(); // Noncompliant, literal should not be used as function +---- + +This rule also detects when a literal is used as a _tag_ function. + +[source,js] +---- +true``; // Noncompliant, literal should not be used as tag function +---- + +== Resources +=== Documentation + +* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions[Functions] +* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals[Template literals] diff --git a/rules/S6958/metadata.json b/rules/S6958/metadata.json new file mode 100644 index 00000000000..7317b707bbb --- /dev/null +++ b/rules/S6958/metadata.json @@ -0,0 +1,25 @@ +{ + "title": "Literals should not be used as functions", + "type": "BUG", + "code": { + "impacts": { + "RELIABILITY": "HIGH" + }, + "attribute": "LOGICAL" + }, + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "5min" + }, + "defaultSeverity": "Critical", + "ruleSpecification": "RSPEC-6958", + "sqKey": "S6958", + "scope": "Main", + "defaultQualityProfiles": [ + "Sonar way" + ], + "quickfix": "infeasible", + "tags": [ + ] +} \ No newline at end of file