-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create rule S6958: Literals should not be used as functions (#3812)
- Loading branch information
1 parent
ee3c651
commit 1df4ed5
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [ | ||
] | ||
} |