this
许多编码风格不鼓励使用 this 来消除代码引用的歧义,并且很容易通过自动重构变得不必要。
示例:
class Foo { int x; void foo() { this.x = 2; } }
在应用快速修复后:
class Foo { int x; void foo() { x = 2; } }
使用检查设置来忽略对字段的赋值。 例如,this.x = 2; 不会被报告,但 int y = this.x; 会被报告。
this.x = 2;
int y = this.x;