Skip to content

Commit

Permalink
SONARPHP-772: fix parseInt exception (#558)
Browse files Browse the repository at this point in the history
* check for too long values in exceptions

* simplify exceptions condition
  • Loading branch information
karim-ouerghemmi-sonarsource authored May 27, 2020
1 parent 7817709 commit 01929a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ private void checkNumericValue(LiteralTree tree) {
/**
* This rule should not apply to values smaller than 8 and octal values having 3 digits,
* since 3 digits octal values are often used as file permission masks.
* Also values like "03" should not raise an issue because they are used in dates.
*/
private static boolean isException(String value) {
return value.length() == 4 || Integer.parseInt(value) < 8;
return value.length() == 4 || value.length() == 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$a = "01234"; // Compliant
$a = 0_1; // Compliant
$a = 0_1234; // Noncompliant
$a = 020000000000; // Noncompliant

//--------------------------
// VariableDeclaration
Expand Down

0 comments on commit 01929a7

Please sign in to comment.