rubocop 1.30.0 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/config/default.yml +41 -8
- data/config/obsoletion.yml +2 -0
- data/exe/rubocop +15 -7
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +1 -1
- data/lib/rubocop/cli/command/suggest_extensions.rb +3 -3
- data/lib/rubocop/config.rb +4 -0
- data/lib/rubocop/config_loader.rb +1 -0
- data/lib/rubocop/config_validator.rb +9 -5
- data/lib/rubocop/cop/base.rb +4 -0
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_filename.rb +4 -4
- data/lib/rubocop/cop/bundler/ordered_gems.rb +2 -2
- data/lib/rubocop/cop/corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +3 -3
- data/lib/rubocop/cop/correctors/unused_arg_corrector.rb +1 -1
- data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +31 -16
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +1 -1
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/gemspec/require_mfa.rb +20 -20
- data/lib/rubocop/cop/generator.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -5
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +25 -4
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +4 -4
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +9 -9
- data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +9 -9
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +27 -27
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +17 -11
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +49 -10
- data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +68 -0
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +120 -0
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +10 -10
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +5 -3
- data/lib/rubocop/cop/layout/trailing_empty_lines.rb +7 -7
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +51 -0
- data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +121 -0
- data/lib/rubocop/cop/lint/number_conversion.rb +3 -3
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +5 -5
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -1
- data/lib/rubocop/cop/lint/regexp_as_condition.rb +2 -2
- data/lib/rubocop/cop/lint/struct_new_override.rb +2 -2
- data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -1
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +44 -0
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +36 -12
- data/lib/rubocop/cop/mixin/range_help.rb +7 -3
- data/lib/rubocop/cop/naming/accessor_method_name.rb +3 -1
- data/lib/rubocop/cop/naming/variable_number.rb +17 -17
- data/lib/rubocop/cop/style/accessor_grouping.rb +1 -1
- data/lib/rubocop/cop/style/and_or.rb +8 -8
- data/lib/rubocop/cop/style/arguments_forwarding.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +4 -2
- data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +1 -0
- data/lib/rubocop/cop/style/empty_else.rb +10 -10
- data/lib/rubocop/cop/style/empty_method.rb +16 -1
- data/lib/rubocop/cop/style/encoding.rb +1 -1
- data/lib/rubocop/cop/style/explicit_block_argument.rb +1 -1
- data/lib/rubocop/cop/style/fetch_env_var.rb +9 -2
- data/lib/rubocop/cop/style/format_string_token.rb +48 -17
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +8 -6
- data/lib/rubocop/cop/style/hash_as_last_array_item.rb +1 -1
- data/lib/rubocop/cop/style/hash_except.rb +88 -8
- data/lib/rubocop/cop/style/hash_syntax.rb +2 -2
- data/lib/rubocop/cop/style/implicit_runtime_error.rb +2 -2
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +1 -1
- data/lib/rubocop/cop/style/map_to_hash.rb +1 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/missing_else.rb +24 -24
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -2
- data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
- data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +1 -3
- data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +1 -3
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +19 -7
- data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/redundant_argument.rb +1 -1
- data/lib/rubocop/cop/style/redundant_return.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/rescue_standard_error.rb +10 -10
- data/lib/rubocop/cop/style/safe_navigation.rb +3 -0
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +2 -2
- data/lib/rubocop/cop/style/string_concatenation.rb +5 -6
- data/lib/rubocop/cop/style/struct_inheritance.rb +2 -2
- data/lib/rubocop/cop/style/swap_values.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +1 -1
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cops_documentation_generator.rb +18 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +8 -5
- data/lib/rubocop/formatter/formatter_set.rb +20 -19
- data/lib/rubocop/formatter/git_hub_actions_formatter.rb +15 -2
- data/lib/rubocop/formatter/html_formatter.rb +0 -1
- data/lib/rubocop/formatter/offense_count_formatter.rb +2 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +6 -9
- data/lib/rubocop/formatter.rb +31 -0
- data/lib/rubocop/options.rb +25 -2
- data/lib/rubocop/rake_task.rb +30 -9
- data/lib/rubocop/runner.rb +2 -2
- data/lib/rubocop/server/cache.rb +109 -0
- data/lib/rubocop/server/cli.rb +104 -0
- data/lib/rubocop/server/client_command/base.rb +44 -0
- data/lib/rubocop/server/client_command/exec.rb +59 -0
- data/lib/rubocop/server/client_command/restart.rb +25 -0
- data/lib/rubocop/server/client_command/start.rb +43 -0
- data/lib/rubocop/server/client_command/status.rb +28 -0
- data/lib/rubocop/server/client_command/stop.rb +31 -0
- data/lib/rubocop/server/client_command.rb +26 -0
- data/lib/rubocop/server/core.rb +79 -0
- data/lib/rubocop/server/errors.rb +23 -0
- data/lib/rubocop/server/helper.rb +34 -0
- data/lib/rubocop/server/server_command/base.rb +50 -0
- data/lib/rubocop/server/server_command/exec.rb +34 -0
- data/lib/rubocop/server/server_command/stop.rb +24 -0
- data/lib/rubocop/server/server_command.rb +21 -0
- data/lib/rubocop/server/socket_reader.rb +65 -0
- data/lib/rubocop/server.rb +53 -0
- data/lib/rubocop/version.rb +15 -8
- data/lib/rubocop.rb +7 -26
- metadata +27 -4
- data/lib/rubocop/cop/gemspec/date_assignment.rb +0 -49
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
autoload :Version, 'rubocop/version'
|
14
|
+
|
15
|
+
module Server
|
16
|
+
# @api private
|
17
|
+
module ClientCommand
|
18
|
+
autoload :Base, 'rubocop/server/client_command/base'
|
19
|
+
autoload :Exec, 'rubocop/server/client_command/exec'
|
20
|
+
autoload :Restart, 'rubocop/server/client_command/restart'
|
21
|
+
autoload :Start, 'rubocop/server/client_command/start'
|
22
|
+
autoload :Status, 'rubocop/server/client_command/status'
|
23
|
+
autoload :Stop, 'rubocop/server/client_command/stop'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
#
|
7
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
8
|
+
#
|
9
|
+
# Copyright (c) 2018 Hayato Kawai
|
10
|
+
#
|
11
|
+
# The MIT License (MIT)
|
12
|
+
#
|
13
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
14
|
+
#
|
15
|
+
module RuboCop
|
16
|
+
module Server
|
17
|
+
# The core of server process. It starts TCP server and perform socket communication.
|
18
|
+
# @api private
|
19
|
+
class Core
|
20
|
+
def self.token
|
21
|
+
@token ||= SecureRandom.hex(4)
|
22
|
+
end
|
23
|
+
|
24
|
+
def token
|
25
|
+
self.class.token
|
26
|
+
end
|
27
|
+
|
28
|
+
def start(host, port)
|
29
|
+
$PROGRAM_NAME = "rubocop --server #{Cache.project_dir}"
|
30
|
+
|
31
|
+
require 'rubocop'
|
32
|
+
start_server(host, port)
|
33
|
+
|
34
|
+
demonize if server_mode?
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def demonize
|
40
|
+
Cache.write_port_and_token_files(port: @server.addr[1], token: token)
|
41
|
+
|
42
|
+
pid = fork do
|
43
|
+
Process.daemon(true)
|
44
|
+
Cache.write_pid_file do
|
45
|
+
read_socket(@server.accept) until @server.closed?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Process.waitpid(pid)
|
50
|
+
end
|
51
|
+
|
52
|
+
def server_mode?
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
def start_server(host, port)
|
57
|
+
@server = TCPServer.open(host, port)
|
58
|
+
|
59
|
+
puts "RuboCop server starting on #{@server.addr[3]}:#{@server.addr[1]}."
|
60
|
+
end
|
61
|
+
|
62
|
+
def read_socket(socket)
|
63
|
+
SocketReader.new(socket).read!
|
64
|
+
rescue InvalidTokenError
|
65
|
+
socket.puts 'token is not valid.'
|
66
|
+
rescue ServerStopRequest
|
67
|
+
@server.close
|
68
|
+
rescue UnknownServerCommandError => e
|
69
|
+
socket.puts e.message
|
70
|
+
rescue Errno::EPIPE => e
|
71
|
+
warn e.inspect
|
72
|
+
rescue StandardError => e
|
73
|
+
socket.puts e.full_message
|
74
|
+
ensure
|
75
|
+
socket.close
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
module Server
|
14
|
+
# @api private
|
15
|
+
class InvalidTokenError < StandardError; end
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
class ServerStopRequest < StandardError; end
|
19
|
+
|
20
|
+
# @api private
|
21
|
+
class UnknownServerCommandError < StandardError; end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
module Server
|
14
|
+
# This module has a helper memthod for `RuboCop::Server::SocketReader`.
|
15
|
+
# @api private
|
16
|
+
module Helper
|
17
|
+
def self.redirect(stdin: $stdin, stdout: $stdout, stderr: $stderr, &_block)
|
18
|
+
old_stdin = $stdin.dup
|
19
|
+
old_stdout = $stdout.dup
|
20
|
+
old_stderr = $stderr.dup
|
21
|
+
|
22
|
+
$stdin = stdin
|
23
|
+
$stdout = stdout
|
24
|
+
$stderr = stderr
|
25
|
+
|
26
|
+
yield
|
27
|
+
ensure
|
28
|
+
$stdin = old_stdin
|
29
|
+
$stdout = old_stdout
|
30
|
+
$stderr = old_stderr
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
module Server
|
14
|
+
module ServerCommand
|
15
|
+
# Abstract base class for server command.
|
16
|
+
# @api private
|
17
|
+
class Base
|
18
|
+
# Common functionality for working with subclasses of this class.
|
19
|
+
# @api private
|
20
|
+
module Runner
|
21
|
+
def run
|
22
|
+
validate_token!
|
23
|
+
Dir.chdir(@cwd) do
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.inherited(child)
|
30
|
+
super
|
31
|
+
child.prepend Runner
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(args, token: '', cwd: Dir.pwd)
|
35
|
+
@args = args
|
36
|
+
@token = token
|
37
|
+
@cwd = cwd
|
38
|
+
end
|
39
|
+
|
40
|
+
def run; end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def validate_token!
|
45
|
+
raise InvalidTokenError unless Cache.token_path.read == @token
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
module Server
|
14
|
+
module ServerCommand
|
15
|
+
# This class is a server command to execute `rubocop` command using `RuboCop::CLI.new#run`.
|
16
|
+
# @api private
|
17
|
+
class Exec < Base
|
18
|
+
def run
|
19
|
+
Cache.status_path.delete if Cache.status_path.file?
|
20
|
+
# RuboCop output is colorized by default where there is a TTY.
|
21
|
+
# We must pass the --color option to preserve this behavior.
|
22
|
+
@args.unshift('--color') unless %w[--color --no-color].any? { |f| @args.include?(f) }
|
23
|
+
status = RuboCop::CLI.new.run(@args)
|
24
|
+
# This status file is read by `rubocop --server` (`RuboCop::Server::Clientcommand::Exec`).
|
25
|
+
# so that they use the correct exit code.
|
26
|
+
# Status is 1 when there are any issues, and 0 otherwise.
|
27
|
+
Cache.write_status_file(status)
|
28
|
+
rescue SystemExit
|
29
|
+
Cache.write_status_file(1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
module Server
|
14
|
+
module ServerCommand
|
15
|
+
# This class is a server command to stop server process.
|
16
|
+
# @api private
|
17
|
+
class Stop < Base
|
18
|
+
def run
|
19
|
+
raise ServerStopRequest
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
module Server
|
14
|
+
# @api private
|
15
|
+
module ServerCommand
|
16
|
+
autoload :Base, 'rubocop/server/server_command/base'
|
17
|
+
autoload :Exec, 'rubocop/server/server_command/exec'
|
18
|
+
autoload :Stop, 'rubocop/server/server_command/stop'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2018 Hayato Kawai
|
7
|
+
#
|
8
|
+
# The MIT License (MIT)
|
9
|
+
#
|
10
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
11
|
+
#
|
12
|
+
module RuboCop
|
13
|
+
module Server
|
14
|
+
# This class sends the request read from the socket to server.
|
15
|
+
# @api private
|
16
|
+
class SocketReader
|
17
|
+
Request = Struct.new(:header, :body)
|
18
|
+
Header = Struct.new(:token, :cwd, :command, :args)
|
19
|
+
|
20
|
+
def initialize(socket)
|
21
|
+
@socket = socket
|
22
|
+
end
|
23
|
+
|
24
|
+
def read!
|
25
|
+
request = parse_request(@socket.read)
|
26
|
+
|
27
|
+
Helper.redirect(
|
28
|
+
stdin: StringIO.new(request.body),
|
29
|
+
stdout: @socket,
|
30
|
+
stderr: @socket
|
31
|
+
) do
|
32
|
+
create_command_instance(request).run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def parse_request(content)
|
39
|
+
raw_header, *body = content.lines
|
40
|
+
|
41
|
+
Request.new(parse_header(raw_header), body.join)
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse_header(header)
|
45
|
+
token, cwd, command, *args = header.shellsplit
|
46
|
+
Header.new(token, cwd, command, args)
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_command_instance(request)
|
50
|
+
klass = find_command_class(request.header.command)
|
51
|
+
|
52
|
+
klass.new(request.header.args, token: request.header.token, cwd: request.header.cwd)
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_command_class(command)
|
56
|
+
case command
|
57
|
+
when 'stop' then ServerCommand::Stop
|
58
|
+
when 'exec' then ServerCommand::Exec
|
59
|
+
else
|
60
|
+
raise UnknownServerCommandError, "#{command.inspect} is not a valid command"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'platform'
|
4
|
+
|
5
|
+
#
|
6
|
+
# This code is based on https://github.com/fohte/rubocop-daemon.
|
7
|
+
#
|
8
|
+
# Copyright (c) 2018 Hayato Kawai
|
9
|
+
#
|
10
|
+
# The MIT License (MIT)
|
11
|
+
#
|
12
|
+
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
|
13
|
+
#
|
14
|
+
module RuboCop
|
15
|
+
# The bootstrap module for server.
|
16
|
+
# @api private
|
17
|
+
module Server
|
18
|
+
TIMEOUT = 20
|
19
|
+
|
20
|
+
autoload :CLI, 'rubocop/server/cli'
|
21
|
+
autoload :Cache, 'rubocop/server/cache'
|
22
|
+
autoload :ClientCommand, 'rubocop/server/client_command'
|
23
|
+
autoload :Helper, 'rubocop/server/helper'
|
24
|
+
autoload :Core, 'rubocop/server/core'
|
25
|
+
autoload :ServerCommand, 'rubocop/server/server_command'
|
26
|
+
autoload :SocketReader, 'rubocop/server/socket_reader'
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def support_server?
|
30
|
+
RUBY_ENGINE == 'ruby' && !RuboCop::Platform.windows?
|
31
|
+
end
|
32
|
+
|
33
|
+
def running?
|
34
|
+
return false unless support_server? # Never running.
|
35
|
+
|
36
|
+
Cache.dir.exist? && Cache.pid_path.file? && Cache.pid_running?
|
37
|
+
end
|
38
|
+
|
39
|
+
def wait_for_running_status!(expected)
|
40
|
+
start_time = Time.now
|
41
|
+
while Server.running? != expected
|
42
|
+
sleep 0.1
|
43
|
+
next unless Time.now - start_time > TIMEOUT
|
44
|
+
|
45
|
+
warn "running? was not #{expected} after #{TIMEOUT} seconds!"
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
require_relative 'server/errors'
|
data/lib/rubocop/version.rb
CHANGED
@@ -3,13 +3,15 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# This module holds the RuboCop version information.
|
5
5
|
module Version
|
6
|
-
STRING = '1.
|
6
|
+
STRING = '1.31.0'
|
7
7
|
|
8
|
-
MSG = '%<version>s (using Parser %<parser_version>s, '\
|
8
|
+
MSG = '%<version>s (using Parser %<parser_version>s, ' \
|
9
9
|
'rubocop-ast %<rubocop_ast_version>s, ' \
|
10
10
|
'running on %<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'
|
11
11
|
|
12
|
-
CANONICAL_FEATURE_NAMES = { 'Rspec' => 'RSpec'
|
12
|
+
CANONICAL_FEATURE_NAMES = { 'Rspec' => 'RSpec', 'Graphql' => 'GraphQL', 'Md' => 'Markdown',
|
13
|
+
'Thread_safety' => 'ThreadSafety' }.freeze
|
14
|
+
EXTENSION_PATH_NAMES = { 'rubocop-md' => 'markdown' }.freeze
|
13
15
|
|
14
16
|
# @api private
|
15
17
|
def self.version(debug: false, env: nil)
|
@@ -43,16 +45,21 @@ module RuboCop
|
|
43
45
|
features.map do |loaded_feature|
|
44
46
|
next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
|
45
47
|
|
46
|
-
|
48
|
+
# Get the expected name of the folder containing the extension code.
|
49
|
+
# Usually it would be the same as the extension name. but sometimes authors
|
50
|
+
# can choose slightly different name for their gems, e.g. rubocop-md instead of
|
51
|
+
# rubocop-markdown.
|
52
|
+
feature = EXTENSION_PATH_NAMES.fetch(loaded_feature, match[:feature])
|
53
|
+
|
47
54
|
begin
|
48
55
|
require "rubocop/#{feature}/version"
|
49
56
|
rescue LoadError
|
50
57
|
# Not worth mentioning libs that are not installed
|
51
|
-
else
|
52
|
-
next unless (feature_version = feature_version(feature))
|
53
|
-
|
54
|
-
" - #{loaded_feature} #{feature_version}"
|
55
58
|
end
|
59
|
+
|
60
|
+
next unless (feature_version = feature_version(feature))
|
61
|
+
|
62
|
+
" - #{loaded_feature} #{feature_version}"
|
56
63
|
end.compact
|
57
64
|
end
|
58
65
|
|
data/lib/rubocop.rb
CHANGED
@@ -63,7 +63,7 @@ require_relative 'rubocop/cop/mixin/alignment'
|
|
63
63
|
require_relative 'rubocop/cop/mixin/allowed_identifiers'
|
64
64
|
require_relative 'rubocop/cop/mixin/allowed_methods'
|
65
65
|
require_relative 'rubocop/cop/mixin/allowed_pattern'
|
66
|
-
require_relative 'rubocop/cop/mixin/auto_corrector'
|
66
|
+
require_relative 'rubocop/cop/mixin/auto_corrector' # rubocop:todo Naming/InclusiveLanguage
|
67
67
|
require_relative 'rubocop/cop/mixin/check_assignment'
|
68
68
|
require_relative 'rubocop/cop/mixin/check_line_breakable'
|
69
69
|
require_relative 'rubocop/cop/mixin/configurable_max'
|
@@ -160,7 +160,6 @@ require_relative 'rubocop/cop/bundler/gem_version'
|
|
160
160
|
require_relative 'rubocop/cop/bundler/insecure_protocol_source'
|
161
161
|
require_relative 'rubocop/cop/bundler/ordered_gems'
|
162
162
|
|
163
|
-
require_relative 'rubocop/cop/gemspec/date_assignment'
|
164
163
|
require_relative 'rubocop/cop/gemspec/dependency_version'
|
165
164
|
require_relative 'rubocop/cop/gemspec/deprecated_attribute_assignment'
|
166
165
|
require_relative 'rubocop/cop/gemspec/duplicated_assignment'
|
@@ -220,6 +219,8 @@ require_relative 'rubocop/cop/layout/indentation_width'
|
|
220
219
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
221
220
|
require_relative 'rubocop/cop/layout/leading_comment_space'
|
222
221
|
require_relative 'rubocop/cop/layout/leading_empty_lines'
|
222
|
+
require_relative 'rubocop/cop/layout/line_continuation_leading_space'
|
223
|
+
require_relative 'rubocop/cop/layout/line_continuation_spacing'
|
223
224
|
require_relative 'rubocop/cop/layout/line_end_string_concatenation_indentation'
|
224
225
|
require_relative 'rubocop/cop/layout/line_length'
|
225
226
|
require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
|
@@ -278,6 +279,7 @@ require_relative 'rubocop/cop/lint/binary_operator_with_identical_operands'
|
|
278
279
|
require_relative 'rubocop/cop/lint/boolean_symbol'
|
279
280
|
require_relative 'rubocop/cop/lint/circular_argument_reference'
|
280
281
|
require_relative 'rubocop/cop/lint/constant_definition_in_block'
|
282
|
+
require_relative 'rubocop/cop/lint/constant_overwritten_in_rescue'
|
281
283
|
require_relative 'rubocop/cop/lint/constant_resolution'
|
282
284
|
require_relative 'rubocop/cop/lint/debugger'
|
283
285
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
@@ -329,6 +331,7 @@ require_relative 'rubocop/cop/lint/nested_method_definition'
|
|
329
331
|
require_relative 'rubocop/cop/lint/nested_percent_literal'
|
330
332
|
require_relative 'rubocop/cop/lint/next_without_accumulator'
|
331
333
|
require_relative 'rubocop/cop/lint/no_return_in_begin_end_blocks'
|
334
|
+
require_relative 'rubocop/cop/lint/non_atomic_file_operation'
|
332
335
|
require_relative 'rubocop/cop/lint/non_deterministic_require_order'
|
333
336
|
require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
|
334
337
|
require_relative 'rubocop/cop/lint/number_conversion'
|
@@ -387,6 +390,7 @@ require_relative 'rubocop/cop/lint/uri_escape_unescape'
|
|
387
390
|
require_relative 'rubocop/cop/lint/uri_regexp'
|
388
391
|
require_relative 'rubocop/cop/lint/useless_access_modifier'
|
389
392
|
require_relative 'rubocop/cop/lint/useless_assignment'
|
393
|
+
require_relative 'rubocop/cop/lint/useless_else_without_rescue'
|
390
394
|
require_relative 'rubocop/cop/lint/useless_method_definition'
|
391
395
|
require_relative 'rubocop/cop/lint/useless_ruby2_keywords'
|
392
396
|
require_relative 'rubocop/cop/lint/useless_setter_call'
|
@@ -665,30 +669,7 @@ require_relative 'rubocop/cop/security/open'
|
|
665
669
|
require_relative 'rubocop/cop/security/yaml_load'
|
666
670
|
|
667
671
|
require_relative 'rubocop/cop/team'
|
668
|
-
|
669
|
-
require_relative 'rubocop/formatter/base_formatter'
|
670
|
-
require_relative 'rubocop/formatter/simple_text_formatter'
|
671
|
-
# relies on simple text
|
672
|
-
require_relative 'rubocop/formatter/clang_style_formatter'
|
673
|
-
require_relative 'rubocop/formatter/disabled_config_formatter'
|
674
|
-
require_relative 'rubocop/formatter/emacs_style_formatter'
|
675
|
-
require_relative 'rubocop/formatter/file_list_formatter'
|
676
|
-
require_relative 'rubocop/formatter/fuubar_style_formatter'
|
677
|
-
require_relative 'rubocop/formatter/git_hub_actions_formatter'
|
678
|
-
require_relative 'rubocop/formatter/html_formatter'
|
679
|
-
require_relative 'rubocop/formatter/json_formatter'
|
680
|
-
require_relative 'rubocop/formatter/junit_formatter'
|
681
|
-
require_relative 'rubocop/formatter/markdown_formatter'
|
682
|
-
require_relative 'rubocop/formatter/offense_count_formatter'
|
683
|
-
require_relative 'rubocop/formatter/progress_formatter'
|
684
|
-
require_relative 'rubocop/formatter/quiet_formatter'
|
685
|
-
require_relative 'rubocop/formatter/tap_formatter'
|
686
|
-
require_relative 'rubocop/formatter/worst_offenders_formatter'
|
687
|
-
require_relative 'rubocop/formatter/pacman_formatter'
|
688
|
-
# relies on progress formatter
|
689
|
-
require_relative 'rubocop/formatter/auto_gen_config_formatter'
|
690
|
-
|
691
|
-
require_relative 'rubocop/formatter/formatter_set'
|
672
|
+
require_relative 'rubocop/formatter'
|
692
673
|
|
693
674
|
require_relative 'rubocop/cached_data'
|
694
675
|
require_relative 'rubocop/config'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -255,7 +255,6 @@ files:
|
|
255
255
|
- lib/rubocop/cop/documentation.rb
|
256
256
|
- lib/rubocop/cop/exclude_limit.rb
|
257
257
|
- lib/rubocop/cop/force.rb
|
258
|
-
- lib/rubocop/cop/gemspec/date_assignment.rb
|
259
258
|
- lib/rubocop/cop/gemspec/dependency_version.rb
|
260
259
|
- lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb
|
261
260
|
- lib/rubocop/cop/gemspec/duplicated_assignment.rb
|
@@ -339,6 +338,8 @@ files:
|
|
339
338
|
- lib/rubocop/cop/layout/initial_indentation.rb
|
340
339
|
- lib/rubocop/cop/layout/leading_comment_space.rb
|
341
340
|
- lib/rubocop/cop/layout/leading_empty_lines.rb
|
341
|
+
- lib/rubocop/cop/layout/line_continuation_leading_space.rb
|
342
|
+
- lib/rubocop/cop/layout/line_continuation_spacing.rb
|
342
343
|
- lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb
|
343
344
|
- lib/rubocop/cop/layout/line_length.rb
|
344
345
|
- lib/rubocop/cop/layout/multiline_array_brace_layout.rb
|
@@ -398,6 +399,7 @@ files:
|
|
398
399
|
- lib/rubocop/cop/lint/boolean_symbol.rb
|
399
400
|
- lib/rubocop/cop/lint/circular_argument_reference.rb
|
400
401
|
- lib/rubocop/cop/lint/constant_definition_in_block.rb
|
402
|
+
- lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb
|
401
403
|
- lib/rubocop/cop/lint/constant_resolution.rb
|
402
404
|
- lib/rubocop/cop/lint/debugger.rb
|
403
405
|
- lib/rubocop/cop/lint/deprecated_class_methods.rb
|
@@ -449,6 +451,7 @@ files:
|
|
449
451
|
- lib/rubocop/cop/lint/nested_percent_literal.rb
|
450
452
|
- lib/rubocop/cop/lint/next_without_accumulator.rb
|
451
453
|
- lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb
|
454
|
+
- lib/rubocop/cop/lint/non_atomic_file_operation.rb
|
452
455
|
- lib/rubocop/cop/lint/non_deterministic_require_order.rb
|
453
456
|
- lib/rubocop/cop/lint/non_local_exit_from_iterator.rb
|
454
457
|
- lib/rubocop/cop/lint/number_conversion.rb
|
@@ -507,6 +510,7 @@ files:
|
|
507
510
|
- lib/rubocop/cop/lint/uri_regexp.rb
|
508
511
|
- lib/rubocop/cop/lint/useless_access_modifier.rb
|
509
512
|
- lib/rubocop/cop/lint/useless_assignment.rb
|
513
|
+
- lib/rubocop/cop/lint/useless_else_without_rescue.rb
|
510
514
|
- lib/rubocop/cop/lint/useless_method_definition.rb
|
511
515
|
- lib/rubocop/cop/lint/useless_ruby2_keywords.rb
|
512
516
|
- lib/rubocop/cop/lint/useless_setter_call.rb
|
@@ -878,6 +882,7 @@ files:
|
|
878
882
|
- lib/rubocop/ext/regexp_node.rb
|
879
883
|
- lib/rubocop/ext/regexp_parser.rb
|
880
884
|
- lib/rubocop/file_finder.rb
|
885
|
+
- lib/rubocop/formatter.rb
|
881
886
|
- lib/rubocop/formatter/auto_gen_config_formatter.rb
|
882
887
|
- lib/rubocop/formatter/base_formatter.rb
|
883
888
|
- lib/rubocop/formatter/clang_style_formatter.rb
|
@@ -916,6 +921,24 @@ files:
|
|
916
921
|
- lib/rubocop/rspec/shared_contexts.rb
|
917
922
|
- lib/rubocop/rspec/support.rb
|
918
923
|
- lib/rubocop/runner.rb
|
924
|
+
- lib/rubocop/server.rb
|
925
|
+
- lib/rubocop/server/cache.rb
|
926
|
+
- lib/rubocop/server/cli.rb
|
927
|
+
- lib/rubocop/server/client_command.rb
|
928
|
+
- lib/rubocop/server/client_command/base.rb
|
929
|
+
- lib/rubocop/server/client_command/exec.rb
|
930
|
+
- lib/rubocop/server/client_command/restart.rb
|
931
|
+
- lib/rubocop/server/client_command/start.rb
|
932
|
+
- lib/rubocop/server/client_command/status.rb
|
933
|
+
- lib/rubocop/server/client_command/stop.rb
|
934
|
+
- lib/rubocop/server/core.rb
|
935
|
+
- lib/rubocop/server/errors.rb
|
936
|
+
- lib/rubocop/server/helper.rb
|
937
|
+
- lib/rubocop/server/server_command.rb
|
938
|
+
- lib/rubocop/server/server_command/base.rb
|
939
|
+
- lib/rubocop/server/server_command/exec.rb
|
940
|
+
- lib/rubocop/server/server_command/stop.rb
|
941
|
+
- lib/rubocop/server/socket_reader.rb
|
919
942
|
- lib/rubocop/string_interpreter.rb
|
920
943
|
- lib/rubocop/target_finder.rb
|
921
944
|
- lib/rubocop/target_ruby.rb
|
@@ -930,7 +953,7 @@ metadata:
|
|
930
953
|
homepage_uri: https://rubocop.org/
|
931
954
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
932
955
|
source_code_uri: https://github.com/rubocop/rubocop/
|
933
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
956
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.31/
|
934
957
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
935
958
|
rubygems_mfa_required: 'true'
|
936
959
|
post_install_message:
|