FileRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. FilesReadStringWithCharset
  2. FilesReadString

FilesReadStringWithCharset

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!FileRules\$FilesReadStringWithCharset).* as compiler argument.

Samples

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

 String testFilesReadStringWithCharset() throws IOException {
-    return new String(Files.readAllBytes(Paths.get("foo")), StandardCharsets.ISO_8859_1);
+    return Files.readString(Paths.get("foo"), StandardCharsets.ISO_8859_1);
   }

FilesReadString

SUGGESTION

Simplification

Suppression

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

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!FileRules\$FilesReadString).* as compiler argument.

Samples

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

 String testFilesReadString() throws IOException {
-    return Files.readString(Paths.get("foo"), StandardCharsets.UTF_8);
+    return Files.readString(Paths.get("foo"));
   }

Copyright © 2017-2024 Picnic Technologies BV