Skip to content

Commit

Permalink
Restrict IO classes to only Files (#881)
Browse files Browse the repository at this point in the history
* Lombok <1.18.22 is not compatible with JDK 17

* Restrict IO classes to only Files
  • Loading branch information
agoncal committed Feb 28, 2023
1 parent d4ba78e commit 6427e6a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion rules/rules-reviewed/azure/azure-file-system.windup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<rule id="azure-file-system-01000">
<when>
<or>
<javaclass references="java.io.{*}"/>
<javaclass references="java.io.{ioclasses}"/>
<javaclass references="java.nio.{*}"/>
<javaclass references="org.apache.commons.io.{*}"/>
</or>
Expand All @@ -40,6 +40,9 @@
<link title="Azure Spring Boot Starter for Azure Storage" href="https://search.maven.org/artifact/com.azure.spring/azure-spring-boot-starter-storage"/>
</hint>
</perform>
<where param="ioclasses">
<matches pattern="(File|FileWriter|FileReader|FileInputStream|FileOutputStream)"/>
</where>
</rule>
<rule id="azure-file-system-02000">
<when>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<rule id="azure-file-system-test-01000">
<when>
<not>
<iterable-filter size="3">
<iterable-filter size="5">
<hint-exists message="The application uses Java APIs to read/write from the file system." />
</iterable-filter>
</not>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import java.notnio.File;
import org.apache.commons.io.File;
import org.apache.commons.notio.File;
import java.io.FileWriter;
import java.io.FileReader;

// Should not match the rule
import java.io.IOException;
import java.io.Closeable;
import java.io.Serializable;
import java.io.DefaultFileSystem;

public class FileSystem {

Expand Down

0 comments on commit 6427e6a

Please sign in to comment.