DIfferent styles on different files

10 views
Skip to first unread message

Tomas

unread,
Sep 21, 2016, 7:48:20 AM9/21/16
to checkstyle
Hey guys,

I have in my project "regular files", two kind of special interfaces and special classes. Each of these has its own style. They are distinguishable by class level annotation. Is there a way how can I achieve checking of rules in each kind of source code files? I need something like this:
if (annotation A used) { ... checks for source code type A }
else if (annotation B used) { ... checks for source code type B }
else if (annotation C used) { ... checks for source code type C }
else { ... checks for the rest of the source codes }

Should there be just one .xml file with this if-else condition? Or should I use more .xml files? And in that case how can I map .xml with checks to files that checks should be applied?

Thank you!
Tomas

Roman Ivanov

unread,
Sep 21, 2016, 8:46:55 AM9/21/16
to Tomas, checkstyle
there is no way to execute Checks in different configurations. Checks are configured the same for whole launch (on whole project, ....)

you can play with multiple configurations and multiple launches of checkstyle over your code. That configurations will use filters/suppression to skip undesirable violations on certain set of files. That set of files should be base on filename/path. We do not have ability suppress base on annotation.

another approach is to have one config, certain Check have multiple instances in configuration (that are different by "id"). You need manually suppress non desirable Checks in certain file by "id". If class of type A , you do @SuppressWarnings("typeB, typeC, ...").


--
You received this message because you are subscribed to the Google Groups "checkstyle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tomas

unread,
Sep 21, 2016, 9:40:55 AM9/21/16
to checkstyle, korec...@gmail.com
Thank you Roman,

The second option is not acceptable for me, but using multiple launches of checkstyle when developer selects the configuration is sufficient.

Thanks!
Tomas
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages