|
Top Previous Next |
Targets: All
This report pinpoints unnecessary code that could be deleted, resulting in a smaller amount of code to maintain and search for errors.
Sections:
REDU2-Local identifiers only used at a lower scope REDU3-Local identifiers only used at a lower scope, but in more than one subprogram REDU4-Local identifiers that are set and referenced once REDU5-Local identifiers that possibly are set and referenced once
REDU6-Local identifiers that are set more than once without referencing in-between REDU7-Local identifiers that possibly are set more than once without referencing in-between REDU8-Class fields that are zero-initialized in constructor REDU9-Class fields that possibly are zero-initialized in constructor REDU10-Local long strings that are initialized to empty string
REDU11-Local long strings that possibly are initialized to empty strings REDU12-Functions called only as procedures (result ignored) REDU13-Functions/procedures (methods excluded) only called once REDU14-Methods only called once from other method of the same class REDU15-Unneeded boolean comparisons
REDU16-Boolean assignment can be shortened REDU17-Fields only used in single method REDU18-Consider using interface type REDU20-Common subexpression, consider elimination
REDU21-Default parameter values that can be omitted REDU22-Inconsistent conditions REDU23-Typecasts that possibly can be omitted REDU24-Local identifiers never used
This is a list of all identifiers that are declared but never used. The Delphi compiler (from Delphi 2) also reports this if warnings ($W+) have been turned on during compilation. Most often, you can remove these identifiers. If you remove any identifier, make sure your code still compiles and works properly. A wise habit is to first comment out these declarations, and remove them entirely when you have validated that the code still compiles and works as intended. Also, note that if a subprogram is not used, does not necessarily indicate that it is not needed at all. If it is part of a general unit, the subprogram could very well be used in other applications.
Identifiers (parameters, local variables etc) related to subprograms that are not used, are not reported.
Constructors/destructors are not examined by this section. Also parameters to event handlers, or methods that are referenced in form files, are not reported as unused. The reason is to avoid unnecessary warnings.
Also unused methods of a class that are implemented through interfaces are not reported. In this case, the class has no choice but to implement these methods.
Example:
In this case, the parameter Sender is not reported as unused, since mnuOpen is an event handler.
This section is also generated for multi-projects. __________________________________________________
REDU2-Local identifiers only used at a lower scope
This is a list of all local identifiers that are only used at a lower scope, in nested subprograms. You can declare these identifiers in the local procedures/functions where they are actually used.
Example:
__________________________________________________
REDU3-Local identifiers only used at a lower scope, but in more than one subprogram
This is a list of all local identifiers that are only used at a lower scope, in nested subprograms. You can probably declare these identifiers in the local procedures/functions where they are actually used, unless they should be shared by the nested subprograms.
Example:
__________________________________________________
REDU4-Local identifiers that are set and referenced once
This is a list of all local identifiers that are set and referenced just once. It may be more efficient to skip these intermediate identifiers.
Restrictions: Identifiers that are first set as a var parameter in a call to a subprogram, and afterwards referenced, are not reported. Also, when the identifier is referenced in a loop, it is not reported.
Example:
__________________________________________________
REDU5-Local identifiers that possibly are set and referenced once
This is a list of all local identifiers that possibly are set and referenced just once. They are referenced in unknown fashion, and the parser cannot determine whether they are set or just referenced in these locations. It may be more efficient to skip this intermediate identifier.
Restrictions: Identifiers that are first set as a var parameter in a call to a subprogram, and afterwards referenced, are not reported. Also, when the identifier is referenced in a loop, it is not reported.
Example:
__________________________________________________
REDU6-Local identifiers that are set more than once without referencing in-between
This is a list of all local identifiers that are set (assigned) more than once without referencing in-between. You can probably remove all but the last assignment. It may of course also indicate a coding error.
Example:
__________________________________________________
REDU7-Local identifiers that possibly are set more than once without referencing in-between
This is a list of all local identifiers that are set (assigned) more than once without referencing in-between. They are referenced in unknown fashion, and the parser cannot determine whether they are set or just referenced in these locations. You can probably delete all but the last assignment.
Example:
__________________________________________________
REDU8-Class fields that are zero-initialized in constructor
This is a list of all class fields that are zero-initialized in constructor. Since class fields are automatically zero-initialized when the object is created, there is usually no need to include this code.
Example:
__________________________________________________
REDU9-Class fields that possibly are zero-initialized in constructor
This is a list of all class fields that possibly are zero-initialized in constructor. They are referenced in unknown fashion, and the parser cannot determine whether they are set or just referenced in these locations. Since class fields are automatically zero-initialized when the object is created, there is usually no need to include this code.
Example:
__________________________________________________
REDU10-Local long strings that are initialized to empty string
(Not relevant for BP7 and D1)
This is a list of all local long strings that are initialized to empty strings. An unnecessary action, since long strings are automatically initialized as empty strings upon creation.
Example:
__________________________________________________
REDU11-Local long strings that possibly are initialized to empty strings
(Not relevant for BP7 and D1)
This is a list of all local long strings that are initialized to empty strings. They are referenced in unknown fashion, and the parser cannot determine whether they are set or just referenced in these locations. An unnecessary action, since long strings are automatically initialized as empty strings upon creation.
Example:
__________________________________________________
REDU12-Functions called only as procedures (result ignored)
These functions may possibly better be implemented as procedures, because the result is never used.
This section is also generated for multi-projects.
__________________________________________________
REDU13-Functions/procedures (methods excluded) only called once
The code in these functions/procedures could possibly be included inline instead, avoiding an unnecessary call.
This section is also generated for multi-projects.
__________________________________________________
REDU14-Methods only called once from other method of the same class
These methods are never called from the outside. The code in these methods could possibly be included inline instead, avoiding an unnecessary call.
This section is also generated for multi-projects.
__________________________________________________
REDU15-Unneeded boolean comparisons
This list contains locations with statements like
if bReady = true then
This could be shorter and better written as
if bReady then
__________________________________________________
REDU16-Boolean assignment can be shortened
This list contains locations with statements like
This could be shorter and better written as
__________________________________________________
REDU17-Fields only used in single method
This list contains class or record fields that are only used in a single method. They could probably better be declared as local variables.
__________________________________________________
REDU18-Consider using interface type
This list contains objects which can be declared and implemented as an interface type, instead of as the class type implementing the interface. The advantage is that interface reference counting can be used so you will not have to explicitly free the object.
Example:
The list will not include objects that are not created. These objects are probably just assigned to another object. Another condition that must be met is that the object is of a class that implements exactly one interface.
__________________________________________________
This section lists locations in your code where superfluous parentheses can be removed, simplifying the code.
__________________________________________________
REDU20-Common subexpression, consider elimination
This section lists locations in your code with repeated common subexpressions. Those may be candidates to put into temporary variables to simplify and optimize the code.
Example:
If any of the variables involved in the repeated expressions would have been modified, between the locations, there should not be any warning.
_________________________________________________
REDU21-Default parameter values that can be omitted
This list contains calls to functions or procedures that use default parameters, and where the parameter can be omitted at the call site. The reason is then that the value of the parameter passed is the same as the default parameter value.
Example:
_________________________________________________
REDU22-Inconsistent conditions
This section reports locations with inconsistent conditions. These are places where a condition check is repeated, even if the outcome will be the same as in the previous location.
Example:
_________________________________________________
REDU23-Typecasts that possibly can be omitted
This section reports locations with typecasts that possibly can be omitted. It is locations where the typecast casts the variable to the same type that it already has.
Example:
_________________________________________________
REDU24-Local identifiers never used
This a list of all local identifiers that are declared but never used. It is actually a subset of the REDU1 report section, which reports all identifiers, not only local.
See also:
|