An IntelliJ IDEA plugin that detects code smells in Java code and recommends appropriate refactorings to resolve them. All of the suggested refactorings can be carried out automatically from within the plugin.
Based on JDeodorant Eclipse plugin.
The tool supports several code smells, namely Feature Envy, Type/State Checking, Long Method, and God Class.
Feature Envy occurs when a method uses attributes/methods of another class more than those of the enclosing class. The tool can detect such methods and suggest moving them to a more related class, i.e. perform a Move Method refactoring.
Type Checking relates to cases when an attribute, which determines the outcome of the program, is represented by complicated conditional statements. The tool detects such pieces of code and suggests a Replace Conditional with Polymorphism refactoring.
State Checking relates to cases when a set of conditional statements determine the outcome of the program by comparing the value of a variable representing the current state of an object with a set of named constants. The tool detects sets like this and suggests a Replace Type code with State/Strategy refactoring.
Long Method, as the name suggests, occurs when a method is too long and can be divided into several. For such methods, the tool identifies blocks of code that are responsible for calculating a variable and suggests extracting it into a separate method, i.e. perform an Extract Method refactoring.
God Class is a name given to a large and complex class that contains too many components. The tool identifies sets of attributes and methods in a class that could be moved into a separate class to simplify the understanding of the code, i.e. an Extract Class refactoring can be performed.
The IntelliJDeodorant
tool window will appear in IntelliJ IDEA. Each tab of this window contains a Refresh
button that allows to search for the necessary code smell in the entire project and the table with the results of the search. To apply any refactoring, simply select a suggestion in the table and click the Refactor
button.
If you have any questions about the plugin or want to report any bugs, feel free to contact us using Gitter or GitHub Issues.
If you want to contribute, please create pull requests.