Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ private static boolean areEquivalentStringLiterals(StringLiteral key, StringLite

public BigDecimal parseAsBigDecimal(String numberLiteralValue) {
String numberValue = numberLiteralValue.replace("_", "");
if (numberValue.endsWith("L") || numberValue.endsWith("l")) {
numberValue = numberValue.substring(0, numberValue.length() - 1);
}
if (numberValue.startsWith("0b") || numberValue.startsWith("0B")) {
return new BigDecimal(new BigInteger(numberValue.substring(2), 2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ def strings():
{f"one{p()}": 1, "two": 2, f"one{p()}": 3} # FN (ok)

def numbers():
{1: "one", 2: "two", 3: "three"}
{1: "one", 2: "two", 1: "three"} # Noncompliant
{1.0: "one", 2.0: "two", 3.0: "three"}
{1.0: "one", 2.0: "two", 1.0: "three"} # Noncompliant
{0o1: "one", 0o2: "two", 0O1: "three"} # Noncompliant
{0x1: "one", 0x3: "two", 0X1: "three"} # Noncompliant
{0xB1E70073L: "1", 0xB1E70073L: "1"} # Noncompliant [[only valid for python 2]]
{0xB1E70073l: "1", 0xB1E70073l: "1"} # Noncompliant [[only valid for python 2]]
{0b1: "one", 0o2: "two", 0B1: "three"} # Noncompliant
{True: "one", False: "two", True: "three"} # Noncompliant

Expand Down