Sha256: be1ab2ea1e345210350f4b5e0ad707ee6f984f9d56032d2739bb362cb8714766

Contents?: true

Size: 1.13 KB

Versions: 38

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

#
# This code is based on https://github.com/fohte/rubocop-daemon.
#
# Copyright (c) 2018 Hayato Kawai
#
# The MIT License (MIT)
#
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
#
module RuboCop
  module Server
    module ServerCommand
      # This class is a server command to execute `rubocop` command using `RuboCop::CLI.new#run`.
      # @api private
      class Exec < Base
        def run
          Cache.status_path.delete if Cache.status_path.file?
          # RuboCop output is colorized by default where there is a TTY.
          # We must pass the --color option to preserve this behavior.
          @args.unshift('--color') unless %w[--color --no-color].any? { |f| @args.include?(f) }
          status = RuboCop::CLI.new.run(@args)
          # This status file is read by `rubocop --server` (`RuboCop::Server::Clientcommand::Exec`).
          # so that they use the correct exit code.
          # Status is 1 when there are any issues, and 0 otherwise.
          Cache.write_status_file(status)
        rescue SystemExit
          Cache.write_status_file(1)
        end
      end
    end
  end
end

Version data entries

38 entries across 34 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server/server_command/exec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server/server_command/exec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server/server_command/exec.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/server/server_command/exec.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/server/server_command/exec.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/server/server_command/exec.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/server/server_command/exec.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/server/server_command/exec.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/server/server_command/exec.rb
call_your_name-0.1.0 vendor/bundle/ruby/3.1.0/gems/rubocop-1.48.1/lib/rubocop/server/server_command/exec.rb
rubocop-1.48.1 lib/rubocop/server/server_command/exec.rb
rubocop-1.48.0 lib/rubocop/server/server_command/exec.rb
rubocop-1.47.0 lib/rubocop/server/server_command/exec.rb
zilla-0.2.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.46.0/lib/rubocop/server/server_command/exec.rb
rubocop-1.46.0 lib/rubocop/server/server_command/exec.rb
rubocop-1.45.1 lib/rubocop/server/server_command/exec.rb
rubocop-1.45.0 lib/rubocop/server/server_command/exec.rb
rubocop-1.44.1 lib/rubocop/server/server_command/exec.rb
rubocop-1.44.0 lib/rubocop/server/server_command/exec.rb
rubocop-1.43.0 lib/rubocop/server/server_command/exec.rb