rubocop-yast¶ ↑
This is a plugin for RuboCop a Ruby static code analyzer. It was inspired by Rubocop-Rspec and YCP Zombie Killer.
The goal is to create a Rubocop plugin which can check for YaST specific issues. Optionally it should allow to covert some ugly code parts introduced by the automatic code conversion done by YCP Killer (conversion from YCP to Ruby).
Check the RSpec tests and the Cucumber featuresto see the examples of offense detection and code conversion.
The plugin is currently in early development, always manually check the chages done by the plugin! It can eat your code… ;-)
Installation¶ ↑
The plugin is published at rubygems.org, you can install it using the gem
command:
sudo gem install rubocop-yast
You can also install the latest development version directly from the Git repository, see Building a Gem section below.
Usage¶ ↑
You need to manually load the Yast plugin into RuboCop
to run the extra checks. There are two options:
-
Use
--require rubocop-yast
command line option when invokingrubocop
-
Enable the plugin in
.rubocop.yml
file:“‘yaml require:
-
rubocop-yast
“‘
See the RuboCop documentation.
Configuration¶ ↑
You can configure Rubocop-Yast the same way as the standard RuboCop
checks (see the RuboCop configuration):
# Check for obsolete Builtins.* calls Yast/Builtins: Enabled: true # Check for obsolete Ops.* calls Yast/Ops: Enabled: true # in strict mode all Ops calls are reported # even if they cannot be autocorrected StrictMode: true
Development¶ ↑
Prerequisites¶ ↑
For development you need some extra development gems. The best way is to install them with Bundler. To avoid a possible collision with system gems (esp. RSpec, Yast still uses version 2.14 while rubocop-yast uses 3.1) it is recommended to install the gems into a local subdirectory using:
bundle install --path vendor/bundle
Source Directories¶ ↑
-
{
config/default.yml
} contains the default Cop configurations -
{
lib/rubocop/cop/yast
} contains Yast Cops (the checks which are called from the main rubocop script) -
{
lib/rubocop/yast
} contains libraries used by the Cops -
{
spec
} contains tests, some tests are automatically generated from a MarkDown documentation
Running Tests¶ ↑
bundle exec rake
By default the tests check the code coverage, if it is below 95% the test fails although there was no test failure.
Autocorrecting Rubocop Issues¶ ↑
bundle exec rake rubocop:auto_correct
You can also load the plugin itself to verify that plugin loading works correctly. (Plugin loading is not covered by tests as it needs the base Rubocop framework.)
bundle exec rubocop -r rubocop-yast
Building a Gem¶ ↑
bundle exec rake build
This builds pkg/rubocop-yast-<version>.gem
gem file, it can be installed locally using
sudo gem install --local pkg/rubocop-yast-<version>.gem
Publishing the Gem to Rubygems.org¶ ↑
Increase the version in {lib/rubocop/yast/version.rb
} file and then run:
bundle exec rake release
(Note: You need push permissions at rubygems.org.)