Sha256: 6bdd0109c126977fef2f5315180c0224dda7c8219ae8027a0a56aca1e21556b7

Contents?: true

Size: 897 Bytes

Versions: 46

Compression:

Stored size: 897 Bytes

Contents

require "rubocop"

module Standard
  module Runners
    class Rubocop
      def call(config)
        rubocop_runner = RuboCop::Runner.new(
          config.rubocop_options,
          config.rubocop_config_store
        )

        rubocop_runner.run(config.paths).tap do |success|
          print_errors_and_warnings(success, rubocop_runner)
          print_corrected_code_if_fixing_stdin(config.rubocop_options)
        end
      end

      private

      def print_errors_and_warnings(success, rubocop_runner)
        return unless success

        (rubocop_runner.warnings + rubocop_runner.errors).each do |message|
          warn message
        end
      end

      def print_corrected_code_if_fixing_stdin(rubocop_options)
        return unless rubocop_options[:stdin] && rubocop_options[:auto_correct]

        puts "=" * 20
        print rubocop_options[:stdin]
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
standard-0.1.0 lib/standard/runners/rubocop.rb
standard-0.0.41 lib/standard/runners/rubocop.rb
standard-0.0.40 lib/standard/runners/rubocop.rb
standard-0.0.39 lib/standard/runners/rubocop.rb
standard-0.0.38 lib/standard/runners/rubocop.rb
standard-0.0.37 lib/standard/runners/rubocop.rb