From ddb681eb5c895bf896d8c91bf8a2d291747e4a27 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Fri, 15 Jul 2022 21:26:30 +0300 Subject: [PATCH] #1644 simplified --- src/main/java/org/cactoos/io/HeadInputStream.java | 4 ++-- src/main/java/org/cactoos/number/AvgOf.java | 2 +- src/main/java/org/cactoos/text/Randomized.java | 2 +- src/main/java/org/cactoos/text/TrimmedLeft.java | 2 +- src/main/java/org/cactoos/text/TrimmedRight.java | 2 +- src/test/java/org/cactoos/func/SolidBiFuncTest.java | 2 +- src/test/java/org/cactoos/scalar/RetryTest.java | 3 +-- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/cactoos/io/HeadInputStream.java b/src/main/java/org/cactoos/io/HeadInputStream.java index 2e1689eae..964581916 100644 --- a/src/main/java/org/cactoos/io/HeadInputStream.java +++ b/src/main/java/org/cactoos/io/HeadInputStream.java @@ -67,7 +67,7 @@ public int read() throws IOException { if (this.processed >= this.length) { adjusted = -1; } else { - this.processed = this.processed + 1; + this.processed += 1; adjusted = this.origin.read(); } return adjusted; @@ -82,7 +82,7 @@ public long skip(final long skip) throws IOException { adjusted = skip; } final long skipped = this.origin.skip(adjusted); - this.processed = this.processed + skipped; + this.processed += skipped; return skipped; } diff --git a/src/main/java/org/cactoos/number/AvgOf.java b/src/main/java/org/cactoos/number/AvgOf.java index 8d15d6c5c..ec15ef562 100644 --- a/src/main/java/org/cactoos/number/AvgOf.java +++ b/src/main/java/org/cactoos/number/AvgOf.java @@ -74,7 +74,7 @@ public AvgOf(final Iterable src) { BigDecimal total = BigDecimal.ZERO; long qty = 0; for (final Number value: new IterableOf<>(it)) { - qty = qty + 1; + qty += 1; total = total.add( new BigDecimal(value.toString()) ); diff --git a/src/main/java/org/cactoos/text/Randomized.java b/src/main/java/org/cactoos/text/Randomized.java index 53b9b65a8..e7e504a80 100644 --- a/src/main/java/org/cactoos/text/Randomized.java +++ b/src/main/java/org/cactoos/text/Randomized.java @@ -138,7 +138,7 @@ public Randomized(final Iterable itr, final Scalar len, fina final int length = len.value(); final StringBuilder builder = new StringBuilder(length); final int bound = chrs.size(); - for (int index = 0; index < length; index = index + 1) { + for (int index = 0; index < length; index += 1) { builder.append(chrs.get(rnd.nextInt(bound))); } return builder.toString(); diff --git a/src/main/java/org/cactoos/text/TrimmedLeft.java b/src/main/java/org/cactoos/text/TrimmedLeft.java index 894501344..1ad13a704 100644 --- a/src/main/java/org/cactoos/text/TrimmedLeft.java +++ b/src/main/java/org/cactoos/text/TrimmedLeft.java @@ -49,7 +49,7 @@ public TrimmedLeft(final Text text) { string.charAt(cursor) ) ) { - cursor = cursor + 1; + cursor += 1; } return string.substring(cursor); }, diff --git a/src/main/java/org/cactoos/text/TrimmedRight.java b/src/main/java/org/cactoos/text/TrimmedRight.java index 9aeea93c2..6e0970adc 100644 --- a/src/main/java/org/cactoos/text/TrimmedRight.java +++ b/src/main/java/org/cactoos/text/TrimmedRight.java @@ -44,7 +44,7 @@ public TrimmedRight(final Text text) { string -> { int cursor = string.length() - 1; while (cursor >= 0 && Character.isWhitespace(string.charAt(cursor))) { - cursor = cursor - 1; + cursor -= 1; } return string.substring(0, cursor + 1); }, diff --git a/src/test/java/org/cactoos/func/SolidBiFuncTest.java b/src/test/java/org/cactoos/func/SolidBiFuncTest.java index 5f64f2997..43e3d1b26 100644 --- a/src/test/java/org/cactoos/func/SolidBiFuncTest.java +++ b/src/test/java/org/cactoos/func/SolidBiFuncTest.java @@ -46,7 +46,7 @@ void testThatFuncIsSynchronized() { final BiFunc testable = new SolidBiFunc<>( (first, second) -> { - shared[0] = shared[0] + 1; + shared[0] += 1; return true; } ); diff --git a/src/test/java/org/cactoos/scalar/RetryTest.java b/src/test/java/org/cactoos/scalar/RetryTest.java index 17e7ad18b..58a08e9d4 100644 --- a/src/test/java/org/cactoos/scalar/RetryTest.java +++ b/src/test/java/org/cactoos/scalar/RetryTest.java @@ -122,8 +122,7 @@ void runsScalarMultipleTimesWithWait() throws Exception { Integer.MAX_VALUE, Duration.ofMillis(wait) ).value(); - for (int position = 0; position < executions.size() - 1; position = - position + 1) { + for (int position = 0; position < executions.size() - 1; position += 1) { final int actual = position; new Assertion<>( "Should wait the given time between attempts",