Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


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


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


  • 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:
      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