Skip to content

Commit d92ba37

Browse files
authored
Quality Improvements (#3697)
1 parent 36e63c3 commit d92ba37

File tree

18 files changed

+22
-22
lines changed

18 files changed

+22
-22
lines changed

assertj-core/src/main/java/org/assertj/core/error/AssertJMultipleFailuresError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private boolean hasDescription(String message) {
6868
}
6969

7070
private static boolean isBlank(String str) {
71-
return str == null || str.trim().length() == 0;
71+
return str == null || str.trim().isEmpty();
7272
}
7373

7474
private static String pluralize(int count, String singular, String plural) {

assertj-core/src/main/java/org/assertj/core/error/ShouldHaveMethods.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private ShouldHaveMethods(Class<?> actual, String modifier, boolean declared,
7777
"Expecting%n" +
7878
" %s%n" +
7979
"not to have any " + (declared ? "declared " : "")
80-
+ (modifier != null && modifier.length() > 0 ? modifier + " " : "") + "methods but it has the following:%n" +
80+
+ (modifier != null && !modifier.isEmpty() ? modifier + " " : "") + "methods but it has the following:%n" +
8181
" %s", actual, actualMethodsHavingModifier);
8282
}
8383
}

assertj-core/src/main/java/org/assertj/core/groups/Properties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static Properties<Object> extractProperty(String propertyName) {
7070

7171
private static void checkIsNotNullOrEmpty(String propertyName) {
7272
requireNonNull(propertyName, "The name of the property to read should not be null");
73-
checkArgument(propertyName.length() > 0, "The name of the property to read should not be empty");
73+
checkArgument(!propertyName.isEmpty(), "The name of the property to read should not be empty");
7474
}
7575

7676
@VisibleForTesting

assertj-core/src/main/java/org/assertj/core/internal/Arrays.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void assertContainsOnlyNulls(AssertionInfo info, Failures failures, Object[] act
272272
for (Object element : actual) {
273273
if (element != null) nonNullElements.add(element);
274274
}
275-
if (nonNullElements.size() > 0) throw failures.failure(info, shouldContainOnlyNulls(actual, nonNullElements));
275+
if (!nonNullElements.isEmpty()) throw failures.failure(info, shouldContainOnlyNulls(actual, nonNullElements));
276276
}
277277

278278
void assertContainsExactly(AssertionInfo info, Failures failures, Object actual, Object values) {
@@ -541,7 +541,7 @@ public void assertIsSubsetOf(AssertionInfo info, Failures failures, Object actua
541541
extra.add(actualElement);
542542
}
543543
}
544-
if (extra.size() > 0) {
544+
if (!extra.isEmpty()) {
545545
throw failures.failure(info, shouldBeSubsetOf(actual, values, extra, comparisonStrategy));
546546
}
547547
}
@@ -704,7 +704,7 @@ static <T> void assertIsSortedAccordingToComparator(AssertionInfo info, Failures
704704
try {
705705
List<T> arrayAsList = asList(array);
706706
// empty arrays are considered sorted even if comparator can't be applied to <T>.
707-
if (arrayAsList.size() == 0) return;
707+
if (arrayAsList.isEmpty()) return;
708708
if (arrayAsList.size() == 1) {
709709
// call compare to see if unique element is compatible with comparator.
710710
comparator.compare(arrayAsList.get(0), arrayAsList.get(0));

assertj-core/src/main/java/org/assertj/core/internal/Lists.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void assertIsSortedAccordingToComparator(AssertionInfo info, List<?> actu
183183
try {
184184
// Empty collections are considered sorted even if comparator can't be applied to their element type
185185
// We can't verify that point because of erasure type at runtime.
186-
if (actual.size() == 0) return;
186+
if (actual.isEmpty()) return;
187187
Comparator rawComparator = comparator;
188188
if (actual.size() == 1) {
189189
// Compare unique element with itself to verify that it is compatible with comparator (a ClassCastException is

assertj-core/src/main/java/org/assertj/core/internal/Maps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public <K, V> void assertNoneSatisfy(AssertionInfo info, Map<K, V> actual, BiCon
145145
.map(Optional::get)
146146
.collect(toList());
147147

148-
if (erroneousEntries.size() > 0) throw failures.failure(info, noElementsShouldSatisfy(actual, erroneousEntries));
148+
if (!erroneousEntries.isEmpty()) throw failures.failure(info, noElementsShouldSatisfy(actual, erroneousEntries));
149149
}
150150

151151
private <V, K> Optional<Entry<K, V>> failsRestrictions(Entry<K, V> entry,

assertj-core/src/main/java/org/assertj/core/internal/Paths.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ private void assertIsDirectoryRecursivelyContaining(AssertionInfo info, Path act
458458

459459
private void assertIsDirectoryNotContaining(AssertionInfo info, Path actual, Filter<Path> filter, String filterPresentation) {
460460
List<Path> matchingPaths = filterDirectory(info, actual, filter);
461-
if (matchingPaths.size() > 0) {
461+
if (!matchingPaths.isEmpty()) {
462462
throw failures.failure(info, directoryShouldNotContain(actual, matchingPaths, filterPresentation));
463463
}
464464
}

assertj-core/src/main/java/org/assertj/core/util/Strings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public final class Strings {
3030
* @return {@code true} if the given {@code String} is {@code null} or empty, otherwise {@code false}.
3131
*/
3232
public static boolean isNullOrEmpty(String s) {
33-
return s == null || s.length() == 0;
33+
return s == null || s.isEmpty();
3434
}
3535

3636
/**

assertj-core/src/test/java/org/assertj/core/api/AutoCloseableBDDSoftAssertionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public String toString() {
140140
softly.then(OptionalInt.of(0)).isEqualTo(1);
141141
softly.then(OptionalDouble.of(0.0)).isEqualTo(1.0);
142142
softly.then(OptionalLong.of(0L)).isEqualTo(1L);
143-
softly.then(LocalTime.of(12, 00)).isEqualTo(LocalTime.of(13, 00));
143+
softly.then(LocalTime.of(12, 0)).isEqualTo(LocalTime.of(13, 0));
144144
softly.then(OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC)).isEqualTo(OffsetTime.of(13, 0, 0, 0, ZoneOffset.UTC));
145145
softly.then(OffsetDateTime.MIN).isEqualTo(OffsetDateTime.MAX);
146146

assertj-core/src/test/java/org/assertj/core/api/BDDSoftAssertionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public String toString() {
278278
softly.then(LocalDateTime.now()).withFailMessage("LocalDateTime check").isBefore(LocalDateTime.now().minusSeconds(10));
279279
softly.then(LocalDate.now()).withFailMessage("LocalDate check").isBefore(LocalDate.now().minusDays(1));
280280
softly.then(emptySpliterator()).withFailMessage("Spliterator check").hasCharacteristics(123);
281-
softly.then(new LongAdder()).withFailMessage("LongAdder check").hasValue(123l);
281+
softly.then(new LongAdder()).withFailMessage("LongAdder check").hasValue(123L);
282282
// WHEN
283283
MultipleFailuresError error = catchThrowableOfType(() -> softly.assertAll(), MultipleFailuresError.class);
284284
// THEN

0 commit comments

Comments
 (0)