Create rule S2486: Exceptions should not be ignored (#1667)
Co-authored-by: yassin-kammoun-sonarsource <yassin-kammoun-sonarsource@users.noreply.github.com>
This commit is contained in:
parent
71af260baf
commit
f70e19219b
4
rules/S2486/javascript/message.adoc
Normal file
4
rules/S2486/javascript/message.adoc
Normal file
@ -0,0 +1,4 @@
|
||||
=== Message
|
||||
|
||||
Handle this exception or don't catch it at all.
|
||||
|
2
rules/S2486/javascript/metadata.json
Normal file
2
rules/S2486/javascript/metadata.json
Normal file
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
43
rules/S2486/javascript/rule.adoc
Normal file
43
rules/S2486/javascript/rule.adoc
Normal file
@ -0,0 +1,43 @@
|
||||
include::../description.adoc[]
|
||||
|
||||
== Noncompliant Code Example
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function f() {
|
||||
try {
|
||||
doSomething();
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
== Compliant Solution
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function f() {
|
||||
try {
|
||||
doSomething();
|
||||
} catch (err) {
|
||||
console.log(`Exception while doing something: ${err}`);
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
include::../see.adoc[]
|
||||
|
||||
ifdef::env-github,rspecator-view[]
|
||||
|
||||
'''
|
||||
== Implementation Specification
|
||||
(visible only on this page)
|
||||
|
||||
include::message.adoc[]
|
||||
|
||||
'''
|
||||
== Comments And Links
|
||||
(visible only on this page)
|
||||
|
||||
include::../comments-and-links.adoc[]
|
||||
endif::env-github,rspecator-view[]
|
Loading…
x
Reference in New Issue
Block a user