FileRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!FileRules\$).*
as compiler argument.
Table of contents
PathOfUri
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("PathOfUri")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!FileRules\$PathOfUri).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Path testPathOfUri() {
- return Paths.get(URI.create("foo"));
+ return Path.of(URI.create("foo"));
}
PathOfString
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("PathOfString")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!FileRules\$PathOfString).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Path> testPathOfString() {
- return ImmutableSet.of(Paths.get("foo"), Paths.get("bar", "baz", "qux"));
+ return ImmutableSet.of(Path.of("foo"), Path.of("bar", "baz", "qux"));
}
PathInstance
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("PathInstance")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!FileRules\$PathInstance).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
Path testPathInstance() {
- return Path.of("foo").toFile().toPath();
+ return Path.of("foo");
}
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"));
}
FilesCreateTempFileToFile
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FilesCreateTempFileToFile")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!FileRules\$FilesCreateTempFileToFile).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<File> testFilesCreateTempFileToFile() throws IOException {
return ImmutableSet.of(
- File.createTempFile("foo", "bar"), File.createTempFile("baz", "qux", null));
+ Files.createTempFile("foo", "bar").toFile(), Files.createTempFile("baz", "qux").toFile());
}
FilesCreateTempFileInCustomDirectoryToFile
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("FilesCreateTempFileInCustomDirectoryToFile")
to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!FileRules\$FilesCreateTempFileInCustomDirectoryToFile).*
as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
File testFilesCreateTempFileInCustomDirectoryToFile() throws IOException {
- return File.createTempFile("foo", "bar", new File("baz"));
+ return Files.createTempFile(new File("baz").toPath(), "foo", "bar").toFile();
}