Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#239 Add configuration parameter to magic number check to ignore jdbc setters

Unstable_(example)
wont-fix
None
1
2013-11-12
2013-07-10
Anonymous
No

The magic number check often fires when setting the parameters to prepared statements.

Avoiding this by introducing a variable that you increase is an artificial workaround in order to avoid a warning, and makes the code a tiny bit harder to follow.

This is a patch that introduces an configuration parameter so that the magic number check will ignore those methods.

I see this as a rough draft of the functionality, i have written unittests that work, but the check itself could be made more robust.

1 Attachments

Discussion

  • That was me who filed this patch, sf didn't want to let me register first.

    I presume that i should rework the NullPointerException check and make that more beutiful, but i think i need a pointer in the right direction for that.

     
    • assigned_to: Daniil Yaroslavtsev
     
  • Good job, but:

    1. I see no code that checks if current instance is really a PreparedStatement, only methods filtering by name.
    2. I think that this line:
      aAST.getParent().getParent().getPreviousSibling().getFirstChild().getNextSibling()
      can be refactored to be more clear.
    3. Ignoring an Exception catching is a bad practice, it should be avoided:

    catch(Exception ignore) {}

     
    Last edit: Daniil Yaroslavtsev 2013-10-02
  • Idea is good. But as author does not respond, I am closing this patch. Alexander, if you still want to contribute this code - please fork our new GitHub repo (https://github.com/checkstyle/checkstyle) and prepare the pull request in respect with my objections above.

     
    Last edit: Daniil Yaroslavtsev 2013-11-12
    • status: open --> wont-fix