Skip to main content Link Search Menu Expand Document (external link)

IntStreamRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules.*)) as compiler argument.

Table of contents
  1. IntStreamClosedOpenRange
  2. ConcatOneIntStream
  3. ConcatTwoIntStreams
  4. FilterOuterIntStreamAfterFlatMap
  5. FilterOuterStreamAfterFlatMapToInt
  6. MapOuterIntStreamAfterFlatMap
  7. MapOuterStreamAfterFlatMapToInt
  8. FlatMapOuterIntStreamAfterFlatMap
  9. FlatMapOuterStreamAfterFlatMapToInt
  10. IntStreamFilterSorted
  11. IntStreamIsEmpty
  12. IntStreamIsNotEmpty
  13. IntStreamMin
  14. IntStreamNoneMatch
  15. IntStreamNoneMatch2
  16. IntStreamAnyMatch
  17. IntStreamAllMatch
  18. IntStreamAllMatch2

IntStreamClosedOpenRange

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamClosedOpenRange") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamClosedOpenRange)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testIntStreamClosedOpenRange() {
-    return IntStream.rangeClosed(0, 42 - 1);
+    return IntStream.range(0, 42);
   }

ConcatOneIntStream

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("ConcatOneIntStream") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.ConcatOneIntStream)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testConcatOneIntStream() {
-    return Streams.concat(IntStream.of(1));
+    return IntStream.of(1);
   }

ConcatTwoIntStreams

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("ConcatTwoIntStreams") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.ConcatTwoIntStreams)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testConcatTwoIntStreams() {
-    return Streams.concat(IntStream.of(1), IntStream.of(2));
+    return IntStream.concat(IntStream.of(1), IntStream.of(2));
   }

FilterOuterIntStreamAfterFlatMap

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FilterOuterIntStreamAfterFlatMap") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.FilterOuterIntStreamAfterFlatMap)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testFilterOuterIntStreamAfterFlatMap() {
-    return IntStream.of(1).flatMap(v -> IntStream.of(v * v).filter(n -> n > 1));
+    return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).filter(n -> n > 1);
   }

FilterOuterStreamAfterFlatMapToInt

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FilterOuterStreamAfterFlatMapToInt") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.FilterOuterStreamAfterFlatMapToInt)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testFilterOuterStreamAfterFlatMapToInt() {
-    return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).filter(n -> n > 1));
+    return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).filter(n -> n > 1);
   }

MapOuterIntStreamAfterFlatMap

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("MapOuterIntStreamAfterFlatMap") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.MapOuterIntStreamAfterFlatMap)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testMapOuterIntStreamAfterFlatMap() {
-    return IntStream.of(1).flatMap(v -> IntStream.of(v * v).map(n -> n * 1));
+    return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).map(n -> n * 1);
   }

MapOuterStreamAfterFlatMapToInt

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("MapOuterStreamAfterFlatMapToInt") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.MapOuterStreamAfterFlatMapToInt)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testMapOuterStreamAfterFlatMapToInt() {
-    return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).map(n -> n * 1));
+    return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).map(n -> n * 1);
   }

FlatMapOuterIntStreamAfterFlatMap

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FlatMapOuterIntStreamAfterFlatMap") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.FlatMapOuterIntStreamAfterFlatMap)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testFlatMapOuterIntStreamAfterFlatMap() {
-    return IntStream.of(1).flatMap(v -> IntStream.of(v * v).flatMap(IntStream::of));
+    return IntStream.of(1).flatMap(v -> IntStream.of(v * v)).flatMap(IntStream::of);
   }

FlatMapOuterStreamAfterFlatMapToInt

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("FlatMapOuterStreamAfterFlatMapToInt") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.FlatMapOuterStreamAfterFlatMapToInt)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testFlatMapOuterStreamAfterFlatMapToInt() {
-    return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v).flatMap(IntStream::of));
+    return Stream.of(1).flatMapToInt(v -> IntStream.of(v * v)).flatMap(IntStream::of);
   }

IntStreamFilterSorted

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamFilterSorted") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamFilterSorted)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 IntStream testIntStreamFilterSorted() {
-    return IntStream.of(1, 4, 3, 2).sorted().filter(i -> i % 2 == 0);
+    return IntStream.of(1, 4, 3, 2).filter(i -> i % 2 == 0).sorted();
   }

IntStreamIsEmpty

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamIsEmpty") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamIsEmpty)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testIntStreamIsEmpty() {
     return ImmutableSet.of(
-        IntStream.of(1).count() == 0,
-        IntStream.of(2).count() <= 0,
-        IntStream.of(3).count() < 1,
-        IntStream.of(4).findFirst().isEmpty());
+        IntStream.of(1).findAny().isEmpty(),
+        IntStream.of(2).findAny().isEmpty(),
+        IntStream.of(3).findAny().isEmpty(),
+        IntStream.of(4).findAny().isEmpty());
   }

IntStreamIsNotEmpty

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamIsNotEmpty") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamIsNotEmpty)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testIntStreamIsNotEmpty() {
     return ImmutableSet.of(
-        IntStream.of(1).count() != 0,
-        IntStream.of(2).count() > 0,
-        IntStream.of(3).count() >= 1,
-        IntStream.of(4).findFirst().isPresent());
+        IntStream.of(1).findAny().isPresent(),
+        IntStream.of(2).findAny().isPresent(),
+        IntStream.of(3).findAny().isPresent(),
+        IntStream.of(4).findAny().isPresent());
   }

IntStreamMin

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamMin") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamMin)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 OptionalInt testIntStreamMin() {
-    return IntStream.of(1).sorted().findFirst();
+    return IntStream.of(1).min();
   }

IntStreamNoneMatch

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamNoneMatch") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamNoneMatch)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testIntStreamNoneMatch() {
     IntPredicate pred = i -> i > 0;
     return ImmutableSet.of(
-        !IntStream.of(1).anyMatch(n -> n > 1),
-        IntStream.of(2).allMatch(pred.negate()),
-        IntStream.of(3).filter(pred).findAny().isEmpty());
+        IntStream.of(1).noneMatch(n -> n > 1),
+        IntStream.of(2).noneMatch(pred),
+        IntStream.of(3).noneMatch(pred));
   }

IntStreamNoneMatch2

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamNoneMatch2") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamNoneMatch2)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 boolean testIntStreamNoneMatch2() {
-    return IntStream.of(1).allMatch(n -> !(n > 1));
+    return IntStream.of(1).noneMatch(n -> n > 1);
   }

IntStreamAnyMatch

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamAnyMatch") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamAnyMatch)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Boolean> testIntStreamAnyMatch() {
     return ImmutableSet.of(
-        !IntStream.of(1).noneMatch(n -> n > 1),
-        IntStream.of(2).filter(n -> n > 2).findAny().isPresent());
+        IntStream.of(1).anyMatch(n -> n > 1), IntStream.of(2).anyMatch(n -> n > 2));
   }

IntStreamAllMatch

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamAllMatch") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamAllMatch)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 boolean testIntStreamAllMatch() {
     IntPredicate pred = i -> i > 0;
-    return IntStream.of(1).noneMatch(pred.negate());
+    return IntStream.of(1).allMatch(pred);
   }

IntStreamAllMatch2

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntStreamAllMatch2") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!(IntStreamRules\.IntStreamAllMatch2)) as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 boolean testIntStreamAllMatch2() {
-    return IntStream.of(1).noneMatch(n -> !(n > 1));
+    return IntStream.of(1).allMatch(n -> n > 1);
   }

Copyright © 2017-2023 Picnic Technologies BV