Code Issues
- 5 minutes to read
In This Article
CodeRush Classic supports the following code issues.
#Duplicate Code
#Hints
- Can initialize conditionally
- Can combine initialization with declaration
- Can implement base type constructors
- Can inline temporary variable
- Declaration can be a constant
- Default Value Can Be Assigned
- Delegate can be replaced with lambda expression
- Environment.NewLine can be used
- Field can be made read-only
- ForEach Action can be called
- Implicit variable can be used
- Initializer can be used
- Member can be static
- Nested code can be flattened
- Null coalescing operation can be used
- Partial class has only single part
- Partial method has only single part
- Property can be auto-implemented
- Redundant delegate creation
- Redundant sealed modifier
- Redundant constructor
- Redundant String.Format call
- Redundant ToString call
- String.Compare can be used
- String.Format can be used
- Ternary expression can be used
- Type can be moved to separate file
- Type name does not correspond to file name
JavaScript code issues:
- Assignment to global variable
- Duplicate local declaration
- Duplicate property declaration
- Hides declaration from the outer scope
- Redundant use of this qualifier in the global context
- Suspicious use of the Equal To operator
- Suspicious use of the Unequal To operator
- Suspicious use of this qualifier
- Possibly unassigned variable usage
- Statement is not terminated
#Warnings
- Case statements do not explicitly handle all enum values
- Can declare MVC view
- Class should implement IDisposable
- Default branch is missing
- Catch block is empty
- Fields should be disposed
- Member is not implemented
- Member is obsolete
- Undisposed local
- Virtual member call in constructor
#Errors
- Abstract member cannot be declared in nonabstract class
- Abstract member cannot be marked as sealed
- Abstract member cannot be marked as virtual
- Abstract member cannot be private
- Abstract member cannot declare a body
- Anonymous method cannot have ‘params’ parameter
- Array elements cannot be of static type
- Base type constructors are not implemented
- Cannot create an instance of abstract class
- Cannot create an instance of interface
- Cannot create an instance of static class
- Cannot declare instance member in a static class
- Cannot declare variable of static type
- Cannot inherit from sealed type
- Cannot inherit from special class ‘System.ValueType’
- Cannot inherit from static class
- Cannot override inherited sealed member
- Cannot yield in the body of a catch clause
- Cannot yield in the body of a finally clause
- Cannot yield in the body of a try block with a catch clause
- Constant cannot be marked static
- Constructor cannot call itself
- Constructor must declare a body
- Control cannot leave the body of a finally clause
- Delegate cannot be marked static
- Destructor must declare a body
- Interface events cannot have add or remove accessors
- Extension method cannot have a parameter array used with ‘this’ modifier
- Extension method must be defined in a non-generic static class
- Extension method must be defined in a top level static class
- Extern member cannot declare a body
- Generic class cannot derive from Attribute
- Indexer cannot be static
- Interface cannot contain constructors
- Interface member cannot have a definition
- Interface expected
- Format item index too large
- Keyword ‘base’ is not valid in a static member
- Keyword this (Me) is not valid in a static member
- Lambda expression cannot have ‘params’ parameter
- Member cannot be sealed because it is not an override
- Member must declare a body because it is not marked abstract or extern
- Member names cannot be the same as their enclosing type
- Method must have a return type
- Only class types can contain destructors
- Operator cannot be abstract
- Operator cannot have ‘params’ parameter
- Operator must be declared static and public
- Operator must declare a body
- Overloaded unary operator takes one parameter
- Override member cannot be marked as new
- Override member cannot be marked as virtual
- Override member cannot change access rights
- Parameter modifier ‘this’ should be the first parameter of extension method
- Partial method cannot have access or the virtual, abstract, override, new, sealed, extern modifiers
- Partial method cannot have out parameters
- Partial method must be declared within a partial class or partial struct
- Property cannot have void type
- Protected member cannot be declared in struct
- Protected member in sealed type will be private
- Sealed class cannot be abstract
- Static class cannot be abstract
- Static class cannot be sealed
- Static class cannot contain protected member
- Static constructors cannot have access modifiers
- Static constructors must be parameterless
- Struct cannot contain parameterless constructor
- The params parameter must be a single dimensional array
- The params parameter must be the last parameter in a formal parameter list
- Try statement without catch or finally
- Undeclared element
- Undeclared static resource
- Virtual member cannot be private
- Virtual member cannot be declared in sealed class
- Virtual member cannot be declared in structures
#Dead Code
- Can remove type qualifier
- Empty switch statement
- Empty event handler
- Empty finally block
- Empty namespace declaration
- Redundant base constructor call
- Redundant base qualifier
- Redundant destructor
- Redundant else statement
- Redundant field initialization
- Lambda parameter has redundant type specification
- Redundant namespace reference
- Redundant private setter
- Redundant this qualifier
- Redundant type qualifier
- Unused member
- Unused declaration
- Unused setter
- Unused type parameter