
## Review A dedicated reviewer checked the rule description successfully for: - [ ] logical errors and incorrect information - [ ] information gaps and missing content - [ ] text style and tone - [ ] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule) --------- Co-authored-by: Peter Trifanov <peter.trifanov@sonarsource.com>
64 lines
1.1 KiB
Plaintext
64 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
== How to fix it
|
|
|
|
include::../how-to-fix.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,js,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
function computeDurationInMilliseconds(hours, minutes, seconds) {
|
|
const duration = (((hours * 60) + minutes) * 60 + seconds) * 1000;
|
|
return duration;
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,js,diff-id=1,diff-type=compliant]
|
|
----
|
|
function computeDurationInMilliseconds(hours, minutes, seconds) {
|
|
return (((hours * 60) + minutes) * 60 + seconds) * 1000;
|
|
}
|
|
----
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,js,diff-id=2,diff-type=noncompliant]
|
|
----
|
|
function doSomething() {
|
|
const myError = new Error();
|
|
throw myError;
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,js,diff-id=2,diff-type=compliant]
|
|
----
|
|
function doSomething() {
|
|
throw new Error();
|
|
}
|
|
----
|
|
|
|
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[]
|