GithubHelp home page GithubHelp logo

try-with-resources-checker's Introduction

Try-with-resources Zip(Input|Output)Stream check plugin

Example usage.

Add compiler configuration (requires Oracle javac 8):

<build>
  ...
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
      <fork>true</fork>
      <forceJavacCompilerUse>true</forceJavacCompilerUse>
      <compilerArgs>
        <arg>-processorpath</arg>
        <arg>${settings.localRepository}${file.separator}eu${file.separator}nets${file.separator}distribution${file.separator}try-with-resources-checker${file.separator}1-SNAPSHOT${file.separator}try-with-resources-checker-1-SNAPSHOT.jar</arg>
        <arg>-Xplugin:TryWithCheckPluginHardline</arg>
        <!-- <arg>-Xplugin:TryWithCheckPlugin</arg> --><!-- Will give Warning on compilation instead of Error -->
        <!-- <arg>-Xplugin:SystemErrOutUsageCheck</arg> --><!-- Will give Error on usage of System.(err|out) -->
      </compilerArgs>
      <encoding>UTF-8</encoding>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>eu.nets.distribution</groupId>
        <artifactId>try-with-resources-checker</artifactId>
        <version>1-SNAPSHOT</version>
      </dependency>
    </dependencies>
  </plugin>
  ...
</build>

Running "mvn clean compile" for input

public class Demo {
    public static void main(String[] args) {
        ZipInputStream unssafe = new ZipInputStream(null);
    }
}

should give

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project nets-distribution: Compilation failure
[ERROR] C:\devel\...\src\main\java\eu\nets\distribution\Demo.java:[7,33] error: Use try-with-resources, offending class was java.util.zip.ZipInputStream

try-with-resources-checker's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.