General bad smell metrics and warnings

In the community of computer programming, bad code smell is a jargon term used among programmers to refer to a symptom which indicates that something may be wrong in the source code. It generally indicates that the code should be refactored or the overall design should be reexamined. Note that a bad smell is only a hint that something might be wrong, not a certainty.

LF

Long Function.

Object-oriented programs that use short methods are easier to understand and maintain. A lot of metrics like LOC (Lines Of Code) and lLOC (logical Lines Of Code) are used to measure how long a method or a function is. But in some cases these metrics do not give correct information about the length of a function because they do not consider how long a line is. In the case of Long Function bad smell we count every programming element (like keywords, literals, operators, etc.) in a function. If this value is at least 'Min', we concider it a Long Function.

LPL

Long Parameter List.

In object-oriented programing we do not have to pass every parameter to a function or a method, only the ones that are necessary for the good operation. Long parameter lists can be hard to understand, they become inconsistent and hard to change. If a function has at least 'Min' parameters, we consider it a Long Parameter List bad smell.

LCD

Large Class Data.

If a class has at least 'Min' data member then we consider it as a Large Class Data bad smell.

LCC

Large Class Code.

We sum up the Long Function values in a class, and if this value is at least 'Min' then we consider it as a Large Class Code bad smell.

LC

Lazy Class.

When a class does not doing so much then it is redundant to allocate resources. These lazy classes characteristically employ other classes' members instead of own members. We notice that an interface class cannot considered as a Lazy Class.

LCO

Large Class Object.

When an object instantiated from a class that requires a great amount of memory, it can become dangeorus to the system resources. In the case of the Large Class Object bad smell we count the memory usage of every simple type with its' appropriate value and we use recursion to calculate the record types (class, struct, union). If an instantiated object of a class requires at least 'Min' bytes of memory, we consider the class a Large Class Object.

MM

Middle Man.

Those classes that only forward the requests are called Middle Man. In the case of Middle Man we count those methods that are called by and call at least one other method, and except the call the method has at most 'Max' programming element (like keywords, literals, operators, etc.). We consider a class as a Middle Man if it has at least 'Min' percent ratio of this kind methods.

DC

Data Class.

Classes containing only data members and methods which set (setter) and return the value (getter) of these members, should be declared as structs. We consider a class a Data Class if the ratio of its setter and getter methods among all of its methods is at least 'Min'percent. We consider a method a getter if it has a return statement using at least one class attribute. A method is a setter if it contains an assignment where the left side contains at least one class attribute and the right side contains at least one parameter of the method. In addition a setter method can have at most 'Max' programming elements (like keywords, literals, operators, etc.). We do not consider abstract classes, structs and unions Data Classes.

RB

Refused Bequest.

The protected visibility was introduced to support the inheritance. If the visibility of an inherited member is protected in a child class but this child class does not use this member, it refuses it. We consider this kind of members Refused Bequest bad smells.

TF

Temporary Field.

If a data member is not used in its class and in the descendents of its class, it is redundant to allocate resources for this member. We examine the ratio of methods that do not use the data member in its class and in the descendants of its class. We choose the smallest from these values and if it is at least 'Min', we consider this data member a Temporary Field.

FE

Feature Envy.

Objects are created to package data along with the methods which use these data. Methods that mainly use the data of other classes do not belong to their current class. If a method uses members of other classes instead of the members of its own class in at least 'Min'percent of the cases, we consider the method a Feature Envy bad smell.