Code Formatting and Cleanup
CodeRush includes tools that make you understand the code more easily. It is gained by the code adjustment to appropriate formatting rules and the dirty code cleanup.
Each developer is used to a certain code style. Code formatting in a habitual style simplifies code understanding and speeds up the development process. CodeRush can apply specified formatting rules to the code you are working with. It allows you to fine-tune formatting options for spaces, blank lines, alignment, line breaks and indentation in a variety of code constructs.
The options on each page of the Editor|Code Formatting section are organized as a tree. It enables you to easily locate the desired option. The code sample at the bottom of the option page shows how the current option will affect your code.
CodeRush does not replace your habitual code formatting after installation. By default, CodeRush applies the specified formatting rules only to the code it generates. You can easily make CodeRush apply its formatting rules whenever Visual Studio active language service auto-formats the code. Check the Adjust code style on autoformat option on the Editor|Code Formatting|General options page.
Have too much dirty code in your solution? Waste no time to look for redundant or cumbersome code constructs. Clean up your file, project, or solution in seconds with CodeRush. It analyzes the code and applies certain refactorings where needed.
To start cleanup, click the Cleanup button on the DXCore Visualize toolbar or choose the appropriate item from the Solution Explorer context menu.
CodeRush offers you apply any of the following improvements to your code during cleanup. You can customize the cleanup options on the Editor|Code Cleanup|Code Cleanup option page.
- Convert "" to string.Empty
- Force braces in "do", "while" statements
- Force braces in "fixed" statement
- Force braces in "for", "foreach" statements
- Force braces in "if..else" statement
- Force braces in "using", "lock" statements
- Make properties auto-implemented
- Remove all comments, excluding XML comments
- Remove all regions
- Remove unreachable code
- Remove unused namespace references
- Remove unused variables
- Remove user blocks
- Sort enum elements
- Use explicit internal modifier
- Use explicit private modifier
If you check the Format Code option on the Editor|Code Cleanup|Code Cleanup options page, CodeRush applies formatting rules after cleanup has been performed.