Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/bulkFileAttributesRead/beforeMethodThrowsIOException.java
Artemiy Sartakov 51b6c30a78 BulkFileAttributesReadInspection: added inspection
Inspection reports multiple java.io.File attribute calls in a row. Attribute calls:
- lastModified
- isFile
- isDirectory
- length
It suggests replacing them with a single attributes extraction using java.nio.file.Files.readAttributes method

GitOrigin-RevId: cd2f93645aab9a4cba2e1f87e05b431f0d21ee50
2022-01-31 06:31:09 +00:00

11 lines
262 B
Java

// "Replace with bulk 'Files.readAttributes' call" "true"
import java.io.*;
class Foo {
long isNewFile(File file) throws IOException {
while (file.isDire<caret>ctory()) {
System.out.println(file.isFile());
}
return file.lastModified();
}
}