sonar-go icon indicating copy to clipboard operation
sonar-go copied to clipboard

Rule S1117: Local variables should not shadow class fields

Open agigleux opened this issue 6 years ago • 2 comments

Implements RSPEC-1117

agigleux avatar Mar 09 '18 20:03 agigleux

I wonder if this rule works in Go, I am afraid it doesn't. @janos-ss wdyt?

saberduck avatar Mar 26 '18 13:03 saberduck

The closest thing I can think of in Go:

var a int

func value() int {
	var a int
	return a
}

I think the idea in the rule can be applied here.

However, I'm not sure if a generic implementation is possible, because of the different search spaces. For example in Go we have to compare package scope with function bodies, and in Java class scope with member functions.

ghost avatar Mar 26 '18 13:03 ghost