Skip to content

Files

Latest commit

 

History

History
28 lines (18 loc) · 549 Bytes

assign.md

File metadata and controls

28 lines (18 loc) · 549 Bytes

Pattern: Useless assignment

Issue: -

Description

This rule checks for for assignments of the form <expr> = <expr>. These are almost always unnecessary, and even when they aren't they are usually a mistake. Consider removing such code to increase readability.

Example of incorrect code:

func (s *ST) SetX(x int) {
	x = x // self-assignment of x to x
}

Example of correct code:

func (s *ST) SetX(x int) {
	s.x = x
}

Further Reading