Archive

Posts Tagged ‘Dead Code’

Code Issues of the dead code type for members and blocks

October 18th, 2012 Comments off

Here are several of the code issues, which highlight redundant and unnecessary code blocks that may be safely removed for improving code readability.

Read more…

Code Issues of the dead code type for qualifiers

September 14th, 2012 Comments off

Here are some of the code issues of the dead code type that indicate redundant ‘this’ (‘Me’ in VB), ‘base’ (‘MyBase’ in VB) and type qualifiers.

Read more…

Code Issues for Switch (Select) and Case statements

December 14th, 2011 Comments off

A switch statement executes logic, dependent on the value of a given expression (parameter). The types of values a switch statement operates on can be boolean, enum, integral types, and strings. Each switch statement can contain any number of case statements, but no two case constants within the same switch statement can have the same value. Each case statement defines a value to compare against the original expression. You may also include a default label following all other case statements. If none of the other choices match, then the default choice is taken and its statements are executed. If there is no default label, control is transferred outside the switch.

Read more…

Code Issues – Redundant else statement

March 19th, 2011 Comments off

Cause:

The else statement is redundant when it doesn’t contain any code, and can be safely removed to improve readability. The type of code issue is a dead code.

Sample:

CodeRush Redundant 'else' statement

How to fix:

CodeRush Redundant Else Statement Fix

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: any
Updated: Nov/12/2012
ID: C084

Code Issues – Unused type parameter

February 14th, 2011 Comments off

Cause:

This code issue of a dead code type shows type parameters to a generic type, or method definitions that are not referenced within its scope, and can be removed. In a generic type or method definition, a type parameter is a placeholder for a specific type that a client specifies when they instantiate a variable of the generic type. Removing the unused type parameter may improve readability.

Read more…

Code Issues – Redundant Destructor

February 10th, 2011 Comments off

Cause:

Destructors are invoked automatically, and used to destroy instances of classes. The developer has no control over when the destructor is called, because this is determined by the garbage collector. Redundant destructor is a an empty destructor without any code inside, that can be safely removed.

Read more…

Code Issues – Catch block is empty

February 10th, 2011 Comments off

Cause:

This code issue shows a warning when the catch block is empty. Usually empty catch block is a bad idea, because you are silently swallowing an error condition and then continuing an execution of the program, or the program may simply fail for an unknown reason.

In general, when an exception occurs, it can be thrown up to the caller, or it can be caught in a catch block. When catching an exception, it is recommended to inform the user about the problem, or log it for a future review.

Read more…

Code Issues – Unused setter

January 23rd, 2011 Comments off

Cause:

This code issue shows a dead code when there are unreferenced private property setters. Unused property setters of private properties can be safely removed, which will improve code readability.

Sample:

CodeRush Unused Setter Sample

How to fix:

  • Apply the Remove Setter code fix:

CodeRush Remove Setter Fix

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: any
Updated: Nov/12/2012
ID: C054