Home > Code Analysis > CodeRush Code Issues types overview

CodeRush Code Issues types overview

February 14th, 2011

There are different types of code issues that the Code Analysis technology provides. Each issue is highlighted with the appropriate color, and has its own icon, depending on its type. These types are:

  • Errors
  • Warnings
  • Hints
  • Dead Code
  • Duplicate Code
  • Code Smells

Errors

Errors are highlighted with a red wavy underline:

CodeRush Error

Code errors indicate that the code is invalid. Errors will definitely lead to the corresponding compile-time errors. Such errors indicate code defects (for example, syntax errors or rules violations of the programming language) that must be fixed before the code can be compiled. Seeing errors in the code editor allows you to fix them before starting the compile process, which may take significant time.

Examples of error code issues:

Warnings

Warnings are highlighted with an orange wavy underline:

CodeRush Warning

Warnings indicate syntactically valid but very suspicious code. A warning indicates you’ve done something bad, but not something that will prevent the code from being compiled. You should fix whatever causes warnings, since they often lead to other problems that will not be so easy to find.

Examples of warning code issues:

Hints

Hints are highlighted with a blue wavy underline:

CodeRush Hint

Hints bring your attention to specific code blocks, and may suggest useful recommendations for their improvement and refactoring. These recommendations can be completely ignored; it is up to you to apply or skip them.

Examples of code hints:

Dead Code

Dead Code issues highlight the source code in gray:

CodeRush Dead Code

Dead code means unnecessary, inoperative code that can be, or better yet, should be removed. You can significantly improve the source code quality by removing dead code. While the functionality won’t be changed, it will improve the internal quality – the readability of the source code. This will help in maintenance by decreasing the maintained code size, making it easier to understand the program, and preventing errors from being introduced.

There are several types of dead code, such as unused declarations (methods, properties, variables, parameters, return values, event handlers, constants, enumerations, classes, interfaces), unreachable code or statement, unused files, unused visual controls, etc.

Examples of Dead Code issues:

Duplicate Code

This type of a code issue highlights duplicated code. Duplicate code occurs two or more times, either within a single program or across different programs. Code duplication is considered an expensive practice that should be avoided because it complicates the maintenance and evolution of the software. The duplicate code is highlighted in purple.

Code Smells

Code Smells are highlighted in green:

CodeRush Code Smell

A code smell is a hint that something might be wrong with your source code, but not necessarily. Smells are indicators of where your code might be hard to read, maintain or evolve, rather than things that are specifically wrong. A smell usually indicates that the code has low quality, for example: large complex methods, long parameters lists, duplicated code, huge classes, inconsistent names, etc.

Sometimes a code smell issue may also detect logic errors. A logic error occurs when your program simply doesn’t do what you want it to.

Examples of code smell issues:

You can tweak colors of code issues inside the Visual Studio Fonts and Colors configuration dialog.

This post is a part of post series about CodeRush Code Issues technology. To learn more about code issues, please refer to the appropriate topics:

  1. Code Issues technology overview
  2. Code Issues types overview (current post)
  3. Code Issues visual presentation
  4. Code Issues fixes and suppression
  5. Code Issues navigation techniques
  6. Code Issues tool window
  7. Code Issues configuration and options
  8. Code Issues overall list
  9. Creating your own code issue
—–
Products: CodeRush Pro
Versions: 11.2 and up
VS IDEs: 2008 and up
Updated: Dec/20/2011
ID: C071

Similar Posts: