From b53d3a13dd77c7c1bc8745d59f4d5aedb110d36d Mon Sep 17 00:00:00 2001 From: castro Date: Mon, 24 Nov 2025 22:43:17 -0300 Subject: [PATCH] fix: ControlStatementBraces code smell --- src/main/java/com/github/javafaker/Color.java | 3 ++- src/main/java/com/github/javafaker/Internet.java | 4 +++- src/main/java/com/github/javafaker/Number.java | 8 ++++++-- .../com/github/javafaker/service/FakeValuesService.java | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/javafaker/Color.java b/src/main/java/com/github/javafaker/Color.java index ec077f494..3871ffa38 100644 --- a/src/main/java/com/github/javafaker/Color.java +++ b/src/main/java/com/github/javafaker/Color.java @@ -17,8 +17,9 @@ public String hex() { public String hex(boolean includeHashSign) { String hexString = faker.random().hex(6); - if(includeHashSign) + if(includeHashSign) { return "#" + hexString; + } return hexString; } } diff --git a/src/main/java/com/github/javafaker/Internet.java b/src/main/java/com/github/javafaker/Internet.java index 163a072e4..c0a0241f9 100644 --- a/src/main/java/com/github/javafaker/Internet.java +++ b/src/main/java/com/github/javafaker/Internet.java @@ -85,7 +85,9 @@ public String avatar() { */ public String image() { String[] dimension = StringUtils.split(faker.fakeValuesService().resolve("internet.image_dimension", this, faker), 'x'); - if (dimension.length == 0) return ""; + if (dimension.length == 0) { + return ""; + } return image( Integer.valueOf(StringUtils.trim(dimension[0])), Integer.valueOf(StringUtils.trim(dimension[1])), faker.bool().bool(), null); diff --git a/src/main/java/com/github/javafaker/Number.java b/src/main/java/com/github/javafaker/Number.java index 3afa93c34..27e4346f7 100644 --- a/src/main/java/com/github/javafaker/Number.java +++ b/src/main/java/com/github/javafaker/Number.java @@ -27,7 +27,9 @@ public int randomDigitNotZero() { * @see Number#numberBetween(long, long) */ public int numberBetween(int min, int max) { - if (min == max) return min; + if (min == max){ + return min;x + } int value = decimalBetween(min,max).setScale(0, BigDecimal.ROUND_HALF_DOWN).intValue(); return value == max ? value - 1 : value; @@ -42,7 +44,9 @@ public int numberBetween(int min, int max) { * @param max exclusive (unless min == max) */ public long numberBetween(long min, long max) { - if (min == max) return min; + if (min == max) { + return min; + } long value = decimalBetween(min, max).setScale(0, BigDecimal.ROUND_HALF_DOWN).longValue(); return value == max ? value - 1 : value; diff --git a/src/main/java/com/github/javafaker/service/FakeValuesService.java b/src/main/java/com/github/javafaker/service/FakeValuesService.java index 13a75b046..71fbe6ea3 100644 --- a/src/main/java/com/github/javafaker/service/FakeValuesService.java +++ b/src/main/java/com/github/javafaker/service/FakeValuesService.java @@ -157,7 +157,9 @@ public String fetchString(String key) { @SuppressWarnings("unchecked") public String safeFetch(String key, String defaultIfNull) { Object o = fetchObject(key); - if (o == null) return defaultIfNull; + if (o == null) { + return defaultIfNull; + } if (o instanceof List) { List values = (List) o; if (values.size() == 0) {