Sha256: 9d0b8e76e08f37d7143712235c8cc5e070c6d10a53bd89ec9f5fa314c2e34f10

Contents?: true

Size: 810 Bytes

Versions: 6

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

require "refinements/io"
require "refinements/pathname"
require "rubocop"

module Rubysmith
  module Extensions
    # Ensures project skeleton adheres to style guide.
    class Rubocop
      include Import[:settings, :logger]

      using Refinements::IO
      using Refinements::Pathname

      def initialize(client: ::RuboCop::CLI.new, **)
        @client = client
        super(**)
      end

      def call
        logger.info { "Running RuboCop autocorrect..." }
        autocorrect
        true
      end

      private

      attr_reader :client

      def autocorrect
        project_root = settings.project_root

        project_root.change_dir do
          STDOUT.squelch { client.run ["--autocorrect-all", project_root.to_s] }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysmith-7.9.0 lib/rubysmith/extensions/rubocop.rb
rubysmith-7.8.0 lib/rubysmith/extensions/rubocop.rb
rubysmith-7.7.0 lib/rubysmith/extensions/rubocop.rb
rubysmith-7.6.0 lib/rubysmith/extensions/rubocop.rb
rubysmith-7.5.0 lib/rubysmith/extensions/rubocop.rb
rubysmith-7.4.0 lib/rubysmith/extensions/rubocop.rb