Sha256: 57bccd1d6308b67a3bce51206933fd28cc5ae162cc3a7efc643aed77b4c185b8

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require "rubocop/stylecheck"
require "fileutils"

def run(options)
  sh "bundle exec rubocop #{options.join(' ')}" do |ok, _res|
    abort "Fix code style errors" unless ok
  end
end

namespace :style do
  namespace :rubocop do
    desc "Run RuboCop with auto_correct"
    task :with_auto_correct do
      run(Rubocop::Stylecheck::Cli.options_with_auto_correct)
    end

    desc "Run RuboCop without auto_correct"
    task :without_auto_correct do
      run(Rubocop::Stylecheck::Cli.options_with_cop)
    end

    desc "Generate local RuboCop config"
    task :generate_local_config do
      template_config_path = Rubocop::Stylecheck.config_path
      project_config_path = Rubocop::Stylecheck.project_config_path

      if template_config_path && File.exist?(template_config_path)
        FileUtils.cp(template_config_path, project_config_path)
      else
        abort "Config file doesn't exist, please use Robocop::Stylecheck.config_path = ..."
      end
    end
  end
end

desc "Check codestyle and fix common errors"
task :style do
  Rake::Task["style:rubocop:with_auto_correct"].invoke
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-stylecheck-0.1.1 lib/rubocop/stylecheck/tasks/rubocop.rake
rubocop-stylecheck-0.1.0 lib/rubocop/stylecheck/tasks/rubocop.rake