Home > Code Analysis > Code Issues – Redundant Constructor

Code Issues – Redundant Constructor

January 23rd, 2011


This code issue shows a hint (suggestion) that a redundant constructor can be safely removed. Redundant constructor is a public, parameterless constructors without any code inside of its body. This constructor doesn’t call base type constructors and it is alone in the current class. The constructor is redundant because such constructors are automatically generated by the compiler. Removing the redundant constructors may improve code readability.


CodeRush Code Issues - Redundant сonstructor

How to fix:

  • Remove the redundant constructor by applying the corresponding Remove Redundant Constructor refactoring:

CodeRush Redundant Constructor Fix 1

  • Add another constructor to the class, so the original constructor is no longer redundant:

CodeRush Redundant Constructor Fix 2

Also, see the full list of code issues specific to constructors.

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

Similar Posts: