Textual changes for "Bulk 'Files.readAttributes()' call can be used" inspection

GitOrigin-RevId: 8ca94e665d8345b4b299415fd3bf43cf22d28c68
This commit is contained in:
Bas Leijdekkers
2022-07-08 18:02:12 +02:00
committed by intellij-monorepo-bot
parent 0cf44fb1ee
commit 7e9ee7537f
23 changed files with 38 additions and 38 deletions

View File

@@ -1,26 +1,26 @@
<html>
<body>
Reports multiple <code>java.io.File</code> attribute checks in a row, such as:
Reports multiple sequential <code>java.io.File</code> attribute checks, such as:
<ul>
<li><code>isDirectory</code></li>
<li><code>isFile</code></li>
<li><code>lastModified</code></li>
<li><code>length</code></li>
<li><code>isDirectory()</code></li>
<li><code>isFile()</code></li>
<li><code>lastModified()</code></li>
<li><code>length()</code></li>
</ul>
These calls can be replaced with a bulk <code>Files.readAttributes</code> call.
Usually the bulk method is more performant then multiple attribute checks.
Such calls can be replaced with a bulk <code>Files.readAttributes()</code> call.
This is usually more performant then multiple separate attribute checks.
<p>Example:</p>
<pre><code>
boolean isNewFile(File file, long lastModified) throws IOException {
return file.isFile() && file.lastModified() > lastModified;
}
boolean isNewFile(File file, long lastModified) throws IOException {
return file.isFile() && file.lastModified() > lastModified;
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
boolean isNewFile(File file, long lastModified) throws IOException {
BasicFileAttributes fileAttributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
return fileAttributes.isRegularFile() && fileAttributes.lastModifiedTime().toMillis() > lastModified;
}
boolean isNewFile(File file, long lastModified) throws IOException {
BasicFileAttributes fileAttributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
return fileAttributes.isRegularFile() && fileAttributes.lastModifiedTime().toMillis() > lastModified;
}
</code></pre>
<!-- tooltip end -->
<p>This inspection does not show a warning if <code>IOException</code> is not handled in the current context, but the quick-fix is still available.</p>

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Fix all 'Bulk 'Files.readAttributes' call can be used instead of multiple file attribute calls' problems in file" "true"
// "Fix all 'Bulk 'Files.readAttributes()' call can be used' problems in file" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "false"
// "Replace with bulk 'Files.readAttributes()' call" "false"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Fix all 'Bulk 'Files.readAttributes' call can be used instead of multiple file attribute calls' problems in file" "true"
// "Fix all 'Bulk 'Files.readAttributes()' call can be used' problems in file" "true"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "false"
// "Replace with bulk 'Files.readAttributes()' call" "false"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "false"
// "Replace with bulk 'Files.readAttributes()' call" "false"
import java.io.*;
class Foo {

View File

@@ -1,4 +1,4 @@
// "Replace with bulk 'Files.readAttributes' call" "true"
// "Replace with bulk 'Files.readAttributes()' call" "true"
import java.io.*;
class Foo {

View File

@@ -1751,9 +1751,9 @@ popup.title.effective.visibility=Effective Visibility
inspection.io.stream.constructor.description='InputStream' and 'OutputStream' can be constructed using 'Files' methods
inspection.input.stream.constructor.message='InputStream' can be constructed using 'Files.newInputStream'
inspection.output.stream.constructor.message='OutputStream' can be constructed using 'Files.newOutputStream'
inspection.bulk.file.attributes.read.description=Bulk 'Files.readAttributes' call can be used instead of multiple file attribute calls
inspection.replace.with.bulk.file.attributes.read.fix.family.name=Replace with bulk 'Files.readAttributes' call
inspection.bulk.file.attributes.read.message=Multiple file attribute calls can be replaced with single 'Files.readAttributes' call
inspection.bulk.file.attributes.read.description=Bulk 'Files.readAttributes()' call can be used
inspection.replace.with.bulk.file.attributes.read.fix.family.name=Replace with bulk 'Files.readAttributes()' call
inspection.bulk.file.attributes.read.message=Multiple file attribute calls can be replaced with single 'Files.readAttributes()' call
external.annotations.problem.title=Unable to read external annotations
external.annotations.problem.parse.error=File: {0}<br>Problem: {1}
external.annotations.open.file=Open annotations file