SONARJAVA-4488 Modify S2130: Use diff'd code samples
This commit is contained in:
parent
8b9df80c13
commit
b348b64d71
@ -6,7 +6,7 @@ Using `parse` makes the code more efficient and the intent of the developer clea
|
|||||||
|
|
||||||
=== Noncompliant code example
|
=== Noncompliant code example
|
||||||
|
|
||||||
[source,java]
|
[source,java,diff-id=1,diff-type=noncompliant]
|
||||||
----
|
----
|
||||||
String myNum = "42.0";
|
String myNum = "42.0";
|
||||||
float myFloat = new Float(myNum); // Noncompliant
|
float myFloat = new Float(myNum); // Noncompliant
|
||||||
@ -18,11 +18,11 @@ int myIntegerValue = Integer.valueOf(myNum).intValue(); // Noncompliant
|
|||||||
|
|
||||||
=== Compliant solution
|
=== Compliant solution
|
||||||
|
|
||||||
[source,java]
|
[source,java,diff-id=1,diff-type=compliant]
|
||||||
----
|
----
|
||||||
String myNum = "42.0";
|
String myNum = "42.0";
|
||||||
float f = Float.parseFloat(myNum); // Compliant
|
float f = Float.parseFloat(myNum);
|
||||||
int myInteger = Integer.parseInt(myNum); // Compliant
|
int myInteger = Integer.parseInt(myNum);
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user