Suppose I need to ensure that all loggers in my scala code are named log
only, not LOGGER
, LOG
or logger
. So for this style checking I need to define a Logger
(for slf4j or log4j) and when style checker detects a variable with this type it check name.
I see org.scalastyle.scalariform.FieldNamesChecker, but do not see any type checkers, so is it possible to do that with scalastyle rules?
Scalastyle only has access to the information in the file, so you might not have the type available.
The best solution is probably to use a Regex. Pretty much all of our loggers have the form:
so you could define a
RegexChecker
with an appropriate regex for your convention. You won't get all of the cases, but you'd probably get most of them.