- This is not the released version of the documentation. Recommended Version
- Tags:
- analysis
- redundant code
CA001 - Self Assignment
Description
Assigning a variable to itself is a meaningless instruction due to a typing error. Most probably, one of the two variable names was misspelled. One example among many others: the programmer wanted to assign a local variable to a class attribute and used one of the variable names twice.
- Scope InstructionStatus EnabledSeverity WarningApplicability AllScore 70
Example of violation
Recommendation
Replace left or right side with something else than the other element.
In the example, replace one of the
See Also: CA071 - Self-comparison
Back to Rules