Sha256: aa01804b738775465eb5541718ac39763b795d32d872b2d001beb8c0e5e7e1b1

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require 'fileutils'

namespace :style do
  namespace :rubocop do
    desc 'Run RuboCop with auto_correct'
    task :with_auto_correct do
      options = ['--rails', '--auto-correct']
      options += ['--fail-level', 'refactor']
      options += ['-c', BookingSync::Stylecheck::RubocopHelpers.config]
      sh "bundle exec rubocop #{options.join(' ')}" do |ok, _res|
        abort 'Fix code style errors' unless ok
      end
    end

    desc 'Run RuboCop without auto_correct'
    task :without_auto_correct do
      options = ['--rails']
      options += ['--fail-level', 'refactor']
      options += ['-c', BookingSync::Stylecheck::RubocopHelpers.config]
      sh "bundle exec rubocop #{options.join(' ')}" do |ok, _res|
        abort 'Fix code style errors' unless ok
      end
    end

    desc "Run RuboCop using the BookingSync config and concatenate custom commands"
    task :custom, [:command_string, :no_fail] do |t, args|
      args[:no_fail] ||= false

      options = ['--rails', '--fail-level', 'refactor']
      options += ['-c', BookingSync::Stylecheck::RubocopHelpers.config]
      options += [args[:command_string]]
      sh "bundle exec rubocop #{options.join(' ')}" do |ok, res|
        abort 'Fix code style errors' if !args[:no_fail] && !ok
      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
bookingsync-stylecheck-0.0.5 lib/bookingsync/tasks/rubocop.rake
bookingsync-stylecheck-0.0.4 lib/bookingsync/tasks/rubocop.rake