https://github.com/walkmod/walkmod-dead-code-cleaner-plugin
Walkmod plugin to remove unused variables, methods and fields
https://github.com/walkmod/walkmod-dead-code-cleaner-plugin
Last synced: 5 months ago
JSON representation
Walkmod plugin to remove unused variables, methods and fields
- Host: GitHub
- URL: https://github.com/walkmod/walkmod-dead-code-cleaner-plugin
- Owner: walkmod
- Created: 2015-03-09T19:38:58.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-10-26T03:08:22.000Z (over 7 years ago)
- Last Synced: 2024-05-28T17:34:00.220Z (about 2 years ago)
- Language: Java
- Size: 42 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.asciidoc
Awesome Lists containing this project
README
walkmod-dead-code-cleaner-plugin
================================
Raquel Pau
image:https://travis-ci.org/walkmod/walkmod-dead-code-cleaner-plugin.svg?branch=master["Build Status", link="https://travis-ci.org/walkmod/walkmod-dead-code-cleaner-plugin"]
This is a walkmod plugin to remove unused declarations (imports, variables and private fields, methods and types) in Java source files.
It applies the clean procedure in cascade. For example, if a unused method uses some types that are just used in this method, the imports
related to these types are also removed.
== Example
Let's see an example. Take a look to this code. There is a private method called `hello` that is never referenced and
also a variable in the `goodBye` method that also is never used.
```java
package example;
import java.util.*;
public class Foo{
private void hello(File file){
...
}
public void goodBye(){
String s="bye";
System.out.println("bye");
}
}
```
What this plugins generates is the following modified code:
```java
package example;
public class Foo{
public void goodBye(){
System.out.println("bye");
}
}
```
== Usage
Check that your walkmod version is at least 2.0.
. Add the https://github.com/rpau/walkmod-maven-plugin[walkmod-maven-plugin] into your `walkmod.xml` as a configuration provider.
This plugin will interpret your classpath accoding your `pom.xml` and will build your project to make the application
classpath available for walkmod.
. Add the transformation `dead-code-cleaner` into your `walkmod.xml`.
```XML
```
You can apply walkmod-dead-code-cleaner-plugin via walkmod.
$ walkmod apply
Or, you can also check which would be the modified classes typing:
$ walkmod check
Optionally, the plugin allows to select which elements are candidates to remove: private types, private methods,
private fields, variables or imports:
```XML
true
true
true
true
true
true
true
true
```
== Contributing
If you want to hack on this, fork it, improve it and send me a pull request.
To get started using it, just clone it and call mvn install.