Why this matters
Overusing var can make code harder to read, especially when the variable type isn't obvious. Use it only when it enhances readability.
var WiselyCheck if var is used only when the variable type is clear and enhances readability. Avoid using var when the type is not obvious.
Overusing var can make code harder to read, especially when the variable type isn't obvious. Use it only when it enhances readability.
Side-by-side examples engineers can pattern-match during review.
var x = 42; // Type is unclear.int x = 42; // Explicit type improves readability.From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.