0

Checkstyle's TrailingComment module detects the following as an invalid trailing comment in line 001:

000 private native void doSomething()/*-{
001    .. javascript code here ..
002 }-*/

Which is of course right, but I want to configure legalComment to ignore them. This is a regular expression, and I expected "-\{" would do the trick. It does not... did anyone have the same problem?

Miquel
  • 15,405
  • 8
  • 54
  • 87

1 Answers1

1

It seems to me that the legalComment pattern is not applied to multiline comments. So you must solve your problem in the format property.

One way of doing that would be to allow trailing comments for native methods, like so:

<module name="TrailingComment">
    <property name="format" value="^(?:.+?\bnative\b.+?|[\s\}\);]*)$"/>
</module>
barfuin
  • 16,865
  • 10
  • 85
  • 132
  • That's a very nice regex, thanks so much! It only does not cover the case where the method name + parameter length is so long that the line is wrapped, in which case, of course, "native" is not present. Because there's no way to identify a JSNI method other than by `native` (and that's not even perfect) and because this rule is not applied to multiline comments, I think your solution's the best possible, so I'm sticking to that. Thanks! – Miquel Jun 19 '13 at 11:15