From 576cafb9d30e3309f454f8b6ba62a561027c6f34 Mon Sep 17 00:00:00 2001 From: Eduarda Moretto Date: Tue, 25 Nov 2025 17:52:11 -0400 Subject: [PATCH 1/2] fix: UselessParentheses code smell --- src/main/java/com/github/javafaker/Address.java | 4 ++-- src/main/java/com/github/javafaker/Code.java | 4 ++-- src/main/java/com/github/javafaker/Finance.java | 2 +- .../java/com/github/javafaker/idnumbers/SvSEIdNumber.java | 4 ++-- .../java/com/github/javafaker/service/FakeValuesService.java | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/github/javafaker/Address.java b/src/main/java/com/github/javafaker/Address.java index ed6b71b82..0a1653c7a 100644 --- a/src/main/java/com/github/javafaker/Address.java +++ b/src/main/java/com/github/javafaker/Address.java @@ -88,11 +88,11 @@ public String lastName() { } public String latitude() { - return String.format("%.8g", (faker.random().nextDouble() * 180) - 90); + return String.format("%.8g", faker.random().nextDouble() * 180 - 90); } public String longitude() { - return String.format("%.8g", (faker.random().nextDouble() * 360) - 180); + return String.format("%.8g", faker.random().nextDouble() * 360 - 180); } public String timeZone() { diff --git a/src/main/java/com/github/javafaker/Code.java b/src/main/java/com/github/javafaker/Code.java index e92517fa2..448584bb3 100644 --- a/src/main/java/com/github/javafaker/Code.java +++ b/src/main/java/com/github/javafaker/Code.java @@ -122,7 +122,7 @@ private final int isbn10CheckDigit(CharSequence t) { String value = stripIsbnSeparator(t); int sum = 0; for (int i = 0; i < value.length(); i++) { - sum += ((i + 1) * toInt(value.substring(i, i + 1))); + sum += (i + 1) * toInt(value.substring(i, i + 1)); } return sum % 11; } @@ -180,7 +180,7 @@ public String imei() { } // Choose the last digit so that it causes the entire string to pass the checksum. - str[len - 1] = Character.forDigit(((10 - (sum % 10)) % 10), 10); + str[len - 1] = Character.forDigit((10 - (sum % 10)) % 10, 10); return new String(str); } diff --git a/src/main/java/com/github/javafaker/Finance.java b/src/main/java/com/github/javafaker/Finance.java index c4eeddf54..0f4114a76 100644 --- a/src/main/java/com/github/javafaker/Finance.java +++ b/src/main/java/com/github/javafaker/Finance.java @@ -35,7 +35,7 @@ public String creditCard(CreditCardType creditCardType) { int luhnSum = 0; int multiplier = 1; for (Integer digit : reversedAsInt) { - multiplier = (multiplier == 2 ? 1 : 2); + multiplier = multiplier == 2 ? 1 : 2; luhnSum += sum(String.valueOf(digit * multiplier).split("")); } int luhnDigit = (10 - (luhnSum % 10)) % 10; diff --git a/src/main/java/com/github/javafaker/idnumbers/SvSEIdNumber.java b/src/main/java/com/github/javafaker/idnumbers/SvSEIdNumber.java index 8bd0d1949..5b22735b0 100644 --- a/src/main/java/com/github/javafaker/idnumbers/SvSEIdNumber.java +++ b/src/main/java/com/github/javafaker/idnumbers/SvSEIdNumber.java @@ -74,10 +74,10 @@ private int calculateChecksum(String number) { String calculatedNumber = calculateDigits(dateString + birthNumber); int sum = calculateDigitSum(calculatedNumber); - int lastDigit = (sum % 10); + int lastDigit = sum % 10; int difference = 10 - lastDigit; - return (difference % 10); + return difference % 10; } private String calculateDigits(String numbers) { diff --git a/src/main/java/com/github/javafaker/service/FakeValuesService.java b/src/main/java/com/github/javafaker/service/FakeValuesService.java index 13a75b046..39008dc00 100644 --- a/src/main/java/com/github/javafaker/service/FakeValuesService.java +++ b/src/main/java/com/github/javafaker/service/FakeValuesService.java @@ -278,7 +278,7 @@ public String letterify(String letterString) { * @return */ public String letterify(String letterString, boolean isUpper) { - return letterHelper((isUpper) ? 65 : 97, letterString); // from ascii table + return letterHelper(isUpper ? 65 : 97, letterString); // from ascii table } private String letterHelper(int baseChar, String letterString) { From 643c28d05c81d578fbd85905b234c194fcb904fc Mon Sep 17 00:00:00 2001 From: Eduarda Moretto Date: Tue, 25 Nov 2025 18:06:11 -0400 Subject: [PATCH 2/2] fix: UnnecessaryModifier code smell --- src/main/java/com/github/javafaker/Code.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/github/javafaker/Code.java b/src/main/java/com/github/javafaker/Code.java index 448584bb3..de2d69ecd 100644 --- a/src/main/java/com/github/javafaker/Code.java +++ b/src/main/java/com/github/javafaker/Code.java @@ -118,16 +118,16 @@ public String isbn13(boolean separator) { return separator ? isbn13.toString() : stripIsbnSeparator(isbn13); } - private final int isbn10CheckDigit(CharSequence t) { + private int isbn10CheckDigit(CharSequence t) { String value = stripIsbnSeparator(t); int sum = 0; for (int i = 0; i < value.length(); i++) { sum += (i + 1) * toInt(value.substring(i, i + 1)); } return sum % 11; - } + } - private final int isbn13CheckDigit(CharSequence t) { + private int isbn13CheckDigit(CharSequence t) { String value = stripIsbnSeparator(t); int sum = 0; int multiplier = 0; @@ -135,12 +135,11 @@ private final int isbn13CheckDigit(CharSequence t) { multiplier = i % 2 == 0 ? 1 : 3; sum += multiplier * toInt(value.subSequence(i, i + 1).toString()); } - - return (10 - sum % 10) % 10; + return sum % 10; } - private final String stripIsbnSeparator(CharSequence t) { - return t.toString().replaceAll("-",""); + private String stripIsbnSeparator(CharSequence t) { + return t.toString().replaceAll("-", ""); } public String asin() {