- edited description
Code inspection to tell you to add this. or super. qualifications to member references
This is clearly an optional item to add to the Inspector
By convention, our org uses this.foo
whenever referring to an object instance variable and super.bar
when referring to a super class variable. Of course, Apex doesn't care but the PR reviewers (sometimes) do care when the developer is inconsistent - this.foo
sometimes but elsewhere in the same class simply foo
.
It would be nice to have a new inspector that would tell you when you forgot to add this.
or super.
to the variable reference - this would be a warning (ochre highlight)
To generalize this, one might have an object variable convention property. In our org's case, this is this.
but in fflib, it is m_
Comments (4)
-
reporter -
reporter - edited description
-
repo owner - changed title to Code inspection to tell you to add this. or super. qualifications to member references
- removed version
- changed component to Code Inspections and Intentions
-
repo owner - changed status to resolved
Eric, this is such a specialized request that I don't feel it's one I'll implement. However, you might be able to implement it as a PMD XPath-based rule for Apex. Might be tricky to determine exactly which references are for members, but I'd recommend investigating that route if this is important to you.
- Log in to comment