Skip to content

Available Code Smells

Felipe Gustavo De Souza Gomes edited this page Oct 7, 2017 · 3 revisions

Here you will find informations about the code smalls that are currently supported. All the code smells implementations can be found in the project rm-core at the package org.repositoryminer.codesmell. Check the Available Metrics page to more information about the code metrics.

God Class

Description: Refers to classes that tend to centralize system intelligence. A God Class does a lot of work by delegating to other classes simpler tasks and using too much data from other classes. The main characteristics of a God Class are: access many data from other classes are large and complex, and have low cohesion among its methods [1].

Detection: ATFD > 5 && WMC >= 47 && TCC < 0.33.

Applies To: Classes.

Brain Method

Description: It refers to methods that tend to center the functionality of the class, just as a God Class tends to centralize the functionality of a subsystem or the entire system. The main characteristics of these methods are: many conditional branches, uses many variables and are long [1].

Detection: LOC > 65 && CYCLO > 7 && MAXNESTING >= 5 && NOAV > 8.

Applies To: Methods.

Brain Class

Description: It refers to classes that tend to accumulate an excessive amount of intelligence, usually in the form of several Brain Method. This disharmony of design is very similar to God Class, since both refer to complex classes, but the two problems are different. The Brain Class Detection Strategy attempts to complement that of God Class by finding classes that are overly complex that are not detected as God Class because they do not access much satellite class data or because they are a bit more cohesive. The main characteristics of these classes are: has more of a Brain Method and are very large, or contains only one Brain Method, but is extremely large and complex, and it is very complex and lacks cohesion [1].

Detection: ((Brain Method > 1 && LOC >= 195) || (Brain Method = 1 && LOC >= 390 && WMC >= 94)) && (WMC >= 47 && TCC < 0.5).

Applies To: Classes.

Data Class

Description: They are classes that only store data and do not have complex functionalities, but the other classes use their data. Lack of relevant functional methods may indicate that that information and behavior are not in the same place. Data Classes represent the lack of encapsulation of information and the detachment of data from functionalities. The main characteristics of these classes are: they offer data instead of services and it reveals many attributes and is not complex [1].

Detection: (WOC < 0.33) && ((NOPA + NOAM) > 5 && WMC < 31) || ((NOPA + NOAM) > 8 && WMC < 47).

Applies To: Classes.

Conditional Complexity

Description: Conditional logic is not a problem at the beginning, when it has few lines and is simple to understand. However, as time passes, logic evolves. Implementing many new features can make conditional logic complicated and expensive. The main characteristic of the code smell are methods with many conditional branches [2].

Detection: CYCLO > 10.

Applies To: Methods.

Long Method

Description: Since very early in programming it is known that the longer the more difficult the function is to understand the. Programs live longer and better when you have small methods. Apart from that, there is currently not much advantage in keeping everything in one's place. For the modern OO language greatly diminished the method call overhead. The main characteristic of this disharmony is the very large methods [3].

Detection: LOC > 65.

Applies To: Methods.

Feature Envy

Description: Objects are a mechanism for keeping together data and the opera- tions that process that data. The Feature Envy design disharmony refers to methods that seem more interested in the data of other classes than that of their own class. These methods access directly or via accessor methods a lot of data of other classes. This might be a sign that the method was misplaced and that it should be moved to another class [1].

Detection: ATFD > 5 && LAA < 0.33 && FDP <= 5.

Applies To: Methods.

References

[1] - LANZA, M.; MARINESCU, R. Object-oriented metrics in practice: using software me- trics to characterize, evaluate, and improve the design of object-oriented systems. [S.l.]: Springer Science & Business Media, 2007.

[2] - KERIEVSKY, J. Refactoring to patterns. [S.l.]: Pearson Deutschland GmbH, 2005.

[3] - FOWLER, M.; BECK, K. Refactoring: improving the design of existing code. [S.l.]: Addison-Wesley Professional, 1999.