#298 RequireThis requires adding "this." to static members

SVN_Head
closed
Other (70)
5
2012-10-10
2005-03-03
kit_
No

When is add "RequireThis" checkers to the configuration
file then it requires adding "this." event to static
members.

Discussion

<< < 1 2 (Page 2 of 2)
  • Logged In: YES
    user_id=505193
    Originator: NO

    The reported error message is confusing. I found out that you have to prefix the class name: Instead of PROPERTY_EVENTNAME use ClassName.PROPERTY_EVENTNAME even if this code is within Classname. I don't consider this to be in the scope of "require this" but in general this seems to be good coding style as you can recognize the location of the constant which is cool if you inherit them.

    kind regards,

    Achim (non-checkstyle member)

     
  • the check works as desined
    Are you serious?
    This is inacceptable. Look at all the duplicates.
    Users really dont think that this is correct behaviour!
    Besides it is common java style to access static members inside the defining class (or if inherited) directly without qualifying your own class.

    Wha is RFE? Radio Free Europe?

     
  • Ah, got it
    RFE = request for enhancement

    Anyways it is a bug!
    this.MY_CONSTANT is NOT good coding style and simply wrong in static methods!!!
    Checkstyle tells me to add "this." even if the method is static.
    But adding "this." will cause a compile error!
    Aint this a bug?

    Please ignore static members in this check and add a new check for static members.

     
  • bug #3022727 closed as duplicate of this ticket

     
  • 2809659 closed as duplicate of this ticket

     
  • I've implemented a simple fix: the check now ignores static fields and members.
    Though I have a feeling that this is not the last problem we have with the check :( Next time we may need to rewrite the test completely.

     
<< < 1 2 (Page 2 of 2)