0.0
No commit activity in last 3 years
No release in over 3 years
This is a plugin for the RuboCop code style checker. It checks for YaST specific issues.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.1.0

Runtime

~> 0.29.1
 Project Readme

rubocop-yast

Gem Version Dependency Status Travis Build Coverage Status Code Climate Inline docs

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 invoking rubocop
  • Enable the plugin in .rubocop.yml file:
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.)