All Projects → gaul → Modernizer Maven Plugin

gaul / Modernizer Maven Plugin

Licence: apache-2.0
Detect uses of legacy Java APIs

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Modernizer Maven Plugin

dmn-check
A tool which performs static analyses on Decision Model Notation (DMN) files to detect bugs
Stars: ✭ 34 (-85.47%)
Mutual labels:  static-analysis, maven-plugin
Php Parser
A PHP parser written in PHP
Stars: ✭ 15,101 (+6353.42%)
Mutual labels:  static-analysis
Awesome Java Security
Awesome Java Security Resources 🕶☕🔐
Stars: ✭ 216 (-7.69%)
Mutual labels:  static-analysis
Protoc Gen Lint
A plug-in for Google's Protocol Buffers (protobufs) compiler to lint .proto files for style violations.
Stars: ✭ 221 (-5.56%)
Mutual labels:  static-analysis
Libscout
LibScout: Third-party library detector for Java/Android apps
Stars: ✭ 217 (-7.26%)
Mutual labels:  static-analysis
Insider
Static Application Security Testing (SAST) engine focused on covering the OWASP Top 10, to make source code analysis to find vulnerabilities right in the source code, focused on a agile and easy to implement software inside your DevOps pipeline. Support the following technologies: Java (Maven and Android), Kotlin (Android), Swift (iOS), .NET Full Framework, C#, and Javascript (Node.js).
Stars: ✭ 216 (-7.69%)
Mutual labels:  static-analysis
Intelephense
Intellisense for PHP
Stars: ✭ 212 (-9.4%)
Mutual labels:  static-analysis
Revive
🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
Stars: ✭ 3,139 (+1241.45%)
Mutual labels:  static-analysis
Check
A set of utilities for checking Go sources. This repository has migrated to https://gitlab.com/opennota/check
Stars: ✭ 225 (-3.85%)
Mutual labels:  static-analysis
Sculptor
Sculptor is a code generator that applies the concepts from Domain-Driven Design and Domain Specific Languages.
Stars: ✭ 220 (-5.98%)
Mutual labels:  maven-plugin
Tfsec
Security scanner for your Terraform code
Stars: ✭ 3,622 (+1447.86%)
Mutual labels:  static-analysis
Bolt
Bolt is a language with in-built data-race freedom!
Stars: ✭ 215 (-8.12%)
Mutual labels:  static-analysis
Codeql Go
The CodeQL extractor and libraries for Go.
Stars: ✭ 224 (-4.27%)
Mutual labels:  static-analysis
Forbidden Apis
Policeman's Forbidden API Checker
Stars: ✭ 216 (-7.69%)
Mutual labels:  static-analysis
Swiftlint
Stars: ✭ 15,500 (+6523.93%)
Mutual labels:  static-analysis
Javafx Maven Plugin
Maven plugin to run JavaFX 11+ applications
Stars: ✭ 213 (-8.97%)
Mutual labels:  maven-plugin
Php Static Analysis Tools
A reviewed list of useful PHP static analysis tools
Stars: ✭ 2,551 (+990.17%)
Mutual labels:  static-analysis
D Scanner
Swiss-army knife for D source code
Stars: ✭ 221 (-5.56%)
Mutual labels:  static-analysis
Inline syscall
Inline syscalls made easy for windows on clang
Stars: ✭ 232 (-0.85%)
Mutual labels:  static-analysis
Docker Maven Plugin
INACTIVE: A maven plugin for Docker
Stars: ✭ 2,597 (+1009.83%)
Mutual labels:  maven-plugin

Modernizer Maven Plugin

Maven Central

Modernizer Maven Plugin detects uses of legacy APIs which modern Java versions supersede. These modern APIs are often more performant, safer, and idiomatic than the legacy equivalents. For example, Modernizer can detect uses of Vector instead of ArrayList, String.getBytes(String) instead of String.getBytes(Charset), and Guava Objects.equal instead of Java 7 Objects.equals. The default configuration detects roughly 200 legacy APIs, including third-party libraries like Apache Commons, Guava, and Joda-Time.

Configuration

To run Modernizer, add the following to the <plugins> stanza in your pom.xml then invoke mvn modernizer:modernizer:

<plugin>
  <groupId>org.gaul</groupId>
  <artifactId>modernizer-maven-plugin</artifactId>
  <version>2.2.0</version>
  <configuration>
    <javaVersion>1.8</javaVersion>
  </configuration>
</plugin>

The <configuration> stanza can contain several elements:

  • <javaVersion> enables violations based on target Java version, e.g., 1.8. For example, Modernizer will detect uses of Vector as violations when targeting Java 1.2 but not when targeting Java 1.1. Required parameter.
  • <failOnViolations> fail phase if Modernizer detects any violations. Defaults to true.
  • <includeTestClasses> run Modernizer on test classes. Defaults to true.
  • <violationsFile> user-specified violation file. Also disables standard violation checks. Can point to classpath using absolute paths, e.g. classpath:/your/file.xml.
  • <violationsFiles> user-specified violations file. The latter files override violations from the former ones, including violationsFile and the default violations. Can point to classpath using absolute paths, e.g. classpath:/your/file.xml.
  • <exclusionsFile> disables user-specified violations. This is a text file with one exclusion per line in the javap format: java/lang/String.getBytes:(Ljava/lang/String;)[B. Empty lines and lines starting with # are ignored.
  • <exclusions> violations to disable. Each exclusion should be in the javap format: java/lang/String.getBytes:(Ljava/lang/String;)[B.
  • <exclusionPatterns> violation patterns to disable, specified using <exclusionPattern> child elements. Each exclusion should be a regular expression that matches the javap format: java/lang/.* of a violation.
  • <ignorePackages> package prefixes to ignore, specified using <ignorePackage> child elements. Specifying foo.bar subsequently ignores foo.bar.*, foo.bar.baz.* and so on.
  • <ignoreClassNamePatterns> full qualified class names (incl. package) to ignore, specified using <ignoreClassNamePattern> child elements. Each exclusion should be a regular expression that matches a package and/or class; the package will be / not . separated (ASM's format).
  • <ignoreGeneratedClasses> classes annotated with an annotation whose retention policy is runtime or class and whose simple name contain "Generated" will be ignored. (Note: both javax.annotation.Generated and javax.annotation.processing.Generated have retention policy SOURCE (aka discarded by compiler).)

To run Modernizer during the verify phase of your build, add the following to the modernizer <plugin> stanza in your pom.xml:

<executions>
  <execution>
    <id>modernizer</id>
    <phase>verify</phase>
    <goals>
      <goal>modernizer</goal>
    </goals>
  </execution>
</executions>

Command-line flags can override Modernizer configuration and ModernizerMojo documents all of these. The most commonly used flags:

  • -Dmodernizer.failOnViolations - fail phase if violations detected, defaults to true
  • -Dmodernizer.skip - skip plugin execution, defaults to false

Ignoring elements

Code can suppress violations within a class or method via an annotation. First add the following dependency to your pom.xml:

<dependencies>
  <dependency>
    <groupId>org.gaul</groupId>
    <artifactId>modernizer-maven-annotations</artifactId>
    <version>2.1.0</version>
  </dependency>
</dependencies>

Then add @SuppressModernizer to the element to ignore:

import org.gaul.modernizer_maven_annotations.SuppressModernizer;

public class Example {
    @SuppressModernizer
    public static void method() { ... }
}

References

License

Copyright (C) 2014-2020 Andrew Gaul

Licensed under the Apache License, Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].