I am new to Checkstyle though I use it mainly through the Maven Checkstyle plugin.
I have a situation where I think Checkstyle lacks flexibility. It could be me, not being familiar with Checkstyle and its configuration options.
The problem I have is with the ParenPad check with a token type of METHOD_CALL; I believe.
In the majority of the cases I don't allow any spaces after nor before the parenthesis in a method call.
e.g. object.method(arg1); Case 1
But when I am using StringBuffer or StringBuilder in building an SQL statement, text for an email or some other long string; I like to provide a LTR feel to the statements used in build up the long string so that it is easier to read.
e.g. buffer.append("String 1 "); Case 2
buffer.append( variable);
buffer.append( " String 2");
The style that I am trying to get is to allow none, one or many spaces after the left parenthesis of a mehod call but no spaces before the right parenthesis of the method call.
It seems that I cannot configure Checkstyle to allow this. I can get it to accept Case 1 and reject Case 2 or visa-versa but to get it to accept both I need to disable the ParenPad test all together which I find too drastic. I want both cases to be accepted and enforced using the checkstyle rules.
Please advise how I might accomplish this using Checkstyle. What configuration do I need? Are there 'tricks' in using Checkstyle to accomplish this? Are there Checkstyle extension to do what I need? Or do I need to write a custom check?
Seeking any help or advice.
Thanks in advance