magic numbers - Java's checkstyle, MagicNumberCheck -
i using checkstyle reportings source-code. question magicnumbercheck.
i using date/(org.joda.)datetime in source code this:
datetime datetime = new datetime(2013, 2, 27, 23, 0): datetime.plushours(57); is there way suppress magicnumbercheck notifications if magic number within date or datetime?
you can use suppressioncommentfilter check this.
configure properties values (in checkstyle configuration file)
<module name="suppressioncommentfilter"> <property name="offcommentformat" value="check\:off\: ([\w\|]+)"/> <property name="oncommentformat" value="check\:on\: ([\w\|]+)"/> <property name="checkformat" value="$1"/> </module> now required lines, can like
//check:off: magicnumber datetime datetime = new datetime(2013, 2, 27, 23, 0): datetime.plushours(57); //check:on: magicnumber this suppress magicnumber checks, rest checks work here.
you can suppress multiple checcks too, like
//check:off: magicnumber|indentation code here //check:on: magicnumber|indentation this suppress magicnumber , indentation checks. other checks work fine.
Comments
Post a Comment