I use rubocop routinely. There’s not really anything you need to specifically customize for openHAB, besides adjusting the TargetRubyVersion
for the version of JRuby you’re running (2.6 for openHAB 3.4, 3.1 for 4.0 and 4.1). I started making an extension to rubocop for making suggestions for better usage of the helper library (rubocop-openhab-scripting), but it’s been low priority and not touched in years, so can’t really recommend it at this point. Overall it’s really up to your personal preferences how you configure rubocop. If you’re not familiar enough with Ruby to develop your own preferences, the Rubocop defaults are a reasonable place to start. You could also look at standardrb or the helper library’s configuration.
My one thought is to be careful of the Style/NumericPredicate cop. I have many instances of received_command rules that compare the command to 0
, but I can’t use #zero?
because it might also be say REFRESH
or STOP
which don’t respond to #zero?
, so the cop’s recommendation is wrong.