You have a temporary variable that is assigned the result of a simple expression and nothing more.
Replace the references to the variable with the expression itself.
- This refactoring technique offers almost no benefit in and of itself. However, if the variable is assigned the result of a method, you can marginally improve the readability of the program by getting rid of the unnecessary variable.
- Sometimes seemingly useless temps are used to cache the result of an expensive operation that is reused several times. So before using this refactoring technique, make sure that simplicity will not come at the cost of performance.
How to Refactor
Find all places that use the variable. Instead of the variable, use the expression that had been assigned to it.
Delete the declaration of the variable and its assignment line.