rubocop 1.52.1 → 1.53.1
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 +1 -1
- data/config/default.yml +38 -1
- data/lib/rubocop/cli/command/lsp.rb +19 -0
- data/lib/rubocop/cli.rb +3 -0
- data/lib/rubocop/config_loader_resolver.rb +4 -3
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_version.rb +2 -2
- data/lib/rubocop/cop/gemspec/dependency_version.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +3 -3
- data/lib/rubocop/cop/layout/class_structure.rb +7 -0
- data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +2 -0
- data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
- data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_hash_key.rb +2 -1
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +46 -19
- data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +1 -1
- data/lib/rubocop/cop/lint/missing_super.rb +31 -5
- data/lib/rubocop/cop/lint/mixed_case_range.rb +109 -0
- data/lib/rubocop/cop/lint/number_conversion.rb +5 -0
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +120 -0
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +8 -3
- data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +1 -1
- data/lib/rubocop/cop/migration/department_name.rb +2 -2
- data/lib/rubocop/cop/mixin/comments_help.rb +1 -1
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +1 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +3 -3
- data/lib/rubocop/cop/style/block_comments.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +3 -3
- data/lib/rubocop/cop/style/conditional_assignment.rb +3 -1
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +1 -1
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +6 -2
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +1 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +1 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +38 -0
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +2 -2
- data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +97 -0
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +2 -1
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +3 -1
- data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
- data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -0
- data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +81 -0
- data/lib/rubocop/cop/style/signal_exception.rb +1 -1
- data/lib/rubocop/cop/style/yaml_file_read.rb +66 -0
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/regexp_ranges.rb +100 -0
- data/lib/rubocop/cops_documentation_generator.rb +1 -1
- data/lib/rubocop/ext/regexp_parser.rb +4 -1
- data/lib/rubocop/lsp/logger.rb +22 -0
- data/lib/rubocop/lsp/routes.rb +223 -0
- data/lib/rubocop/lsp/runtime.rb +79 -0
- data/lib/rubocop/lsp/server.rb +62 -0
- data/lib/rubocop/lsp/severity.rb +27 -0
- data/lib/rubocop/options.rb +11 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +8 -0
- metadata +30 -3
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Lsp
|
5
|
+
# Severity for Language Server Protocol of RuboCop.
|
6
|
+
# @api private
|
7
|
+
class Severity
|
8
|
+
SEVERITIES = {
|
9
|
+
fatal: LanguageServer::Protocol::Constant::DiagnosticSeverity::ERROR,
|
10
|
+
error: LanguageServer::Protocol::Constant::DiagnosticSeverity::ERROR,
|
11
|
+
warning: LanguageServer::Protocol::Constant::DiagnosticSeverity::WARNING,
|
12
|
+
convention: LanguageServer::Protocol::Constant::DiagnosticSeverity::INFORMATION,
|
13
|
+
refactor: LanguageServer::Protocol::Constant::DiagnosticSeverity::HINT,
|
14
|
+
info: LanguageServer::Protocol::Constant::DiagnosticSeverity::HINT
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
def self.find_by(rubocop_severity)
|
18
|
+
if (severity = SEVERITIES[rubocop_severity.to_sym])
|
19
|
+
return severity
|
20
|
+
end
|
21
|
+
|
22
|
+
Logger.log("Unknown severity: #{rubocop_severity}")
|
23
|
+
LanguageServer::Protocol::Constant::DiagnosticSeverity::HINT
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/rubocop/options.rb
CHANGED
@@ -16,7 +16,7 @@ module RuboCop
|
|
16
16
|
'root of the project. RuboCop will use this path to determine which ' \
|
17
17
|
'cops are enabled (via eg. Include/Exclude), and so that certain cops ' \
|
18
18
|
'like Naming/FileName can be checked.'
|
19
|
-
EXITING_OPTIONS = %i[version verbose_version show_cops show_docs_url].freeze
|
19
|
+
EXITING_OPTIONS = %i[version verbose_version show_cops show_docs_url lsp].freeze
|
20
20
|
DEFAULT_MAXIMUM_EXCLUSION_ITEMS = 15
|
21
21
|
|
22
22
|
def initialize
|
@@ -49,12 +49,14 @@ module RuboCop
|
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
+
# rubocop:disable Metrics/AbcSize
|
52
53
|
def define_options
|
53
54
|
OptionParser.new do |opts|
|
54
55
|
opts.banner = rainbow.wrap('Usage: rubocop [options] [file1, file2, ...]').bright
|
55
56
|
|
56
57
|
add_check_options(opts)
|
57
58
|
add_cache_options(opts)
|
59
|
+
add_lsp_option(opts)
|
58
60
|
add_server_options(opts)
|
59
61
|
add_output_options(opts)
|
60
62
|
add_autocorrection_options(opts)
|
@@ -66,6 +68,7 @@ module RuboCop
|
|
66
68
|
add_profile_options(opts) if RUBY_ENGINE == 'ruby' && !Platform.windows?
|
67
69
|
end
|
68
70
|
end
|
71
|
+
# rubocop:enable Metrics/AbcSize
|
69
72
|
|
70
73
|
def add_check_options(opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
71
74
|
section(opts, 'Basic Options') do # rubocop:disable Metrics/BlockLength
|
@@ -205,6 +208,12 @@ module RuboCop
|
|
205
208
|
end
|
206
209
|
end
|
207
210
|
|
211
|
+
def add_lsp_option(opts)
|
212
|
+
section(opts, 'LSP Option') do
|
213
|
+
option(opts, '--lsp')
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
208
217
|
def add_server_options(opts)
|
209
218
|
section(opts, 'Server Options') do
|
210
219
|
option(opts, '--[no-]server')
|
@@ -620,6 +629,7 @@ module RuboCop
|
|
620
629
|
stop_server: 'Stop server process.',
|
621
630
|
server_status: 'Show server status.',
|
622
631
|
no_detach: 'Run the server process in the foreground.',
|
632
|
+
lsp: 'Start a language server listening on STDIN.',
|
623
633
|
raise_cop_error: ['Raise cop-related errors with cause and location.',
|
624
634
|
'This is used to prevent cops from failing silently.',
|
625
635
|
'Default is false.'],
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -139,6 +139,7 @@ require_relative 'rubocop/cop/mixin/comments_help' # relies on visibility_help
|
|
139
139
|
require_relative 'rubocop/cop/mixin/def_node' # relies on visibility_help
|
140
140
|
|
141
141
|
require_relative 'rubocop/cop/utils/format_string'
|
142
|
+
require_relative 'rubocop/cop/utils/regexp_ranges'
|
142
143
|
|
143
144
|
require_relative 'rubocop/cop/migration/department_name'
|
144
145
|
|
@@ -336,6 +337,7 @@ require_relative 'rubocop/cop/lint/literal_in_interpolation'
|
|
336
337
|
require_relative 'rubocop/cop/lint/loop'
|
337
338
|
require_relative 'rubocop/cop/lint/missing_cop_enable_directive'
|
338
339
|
require_relative 'rubocop/cop/lint/missing_super'
|
340
|
+
require_relative 'rubocop/cop/lint/mixed_case_range'
|
339
341
|
require_relative 'rubocop/cop/lint/mixed_regexp_capture_types'
|
340
342
|
require_relative 'rubocop/cop/lint/multiple_comparison'
|
341
343
|
require_relative 'rubocop/cop/lint/nested_method_definition'
|
@@ -358,6 +360,7 @@ require_relative 'rubocop/cop/lint/rand_one'
|
|
358
360
|
require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
359
361
|
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
360
362
|
require_relative 'rubocop/cop/lint/redundant_dir_glob_sort'
|
363
|
+
require_relative 'rubocop/cop/lint/redundant_regexp_quantifiers'
|
361
364
|
require_relative 'rubocop/cop/lint/redundant_require_statement'
|
362
365
|
require_relative 'rubocop/cop/lint/redundant_safe_navigation'
|
363
366
|
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
@@ -562,6 +565,7 @@ require_relative 'rubocop/cop/style/operator_method_call'
|
|
562
565
|
require_relative 'rubocop/cop/style/redundant_array_constructor'
|
563
566
|
require_relative 'rubocop/cop/style/redundant_assignment'
|
564
567
|
require_relative 'rubocop/cop/style/redundant_constant_base'
|
568
|
+
require_relative 'rubocop/cop/style/redundant_current_directory_in_path'
|
565
569
|
require_relative 'rubocop/cop/style/redundant_double_splat_hash_braces'
|
566
570
|
require_relative 'rubocop/cop/style/redundant_each'
|
567
571
|
require_relative 'rubocop/cop/style/redundant_fetch_block'
|
@@ -570,6 +574,7 @@ require_relative 'rubocop/cop/style/redundant_filter_chain'
|
|
570
574
|
require_relative 'rubocop/cop/style/redundant_heredoc_delimiter_quotes'
|
571
575
|
require_relative 'rubocop/cop/style/redundant_initialize'
|
572
576
|
require_relative 'rubocop/cop/style/redundant_line_continuation'
|
577
|
+
require_relative 'rubocop/cop/style/redundant_regexp_argument'
|
573
578
|
require_relative 'rubocop/cop/style/redundant_regexp_constructor'
|
574
579
|
require_relative 'rubocop/cop/style/redundant_self_assignment'
|
575
580
|
require_relative 'rubocop/cop/style/redundant_self_assignment_branch'
|
@@ -648,6 +653,7 @@ require_relative 'rubocop/cop/style/regexp_literal'
|
|
648
653
|
require_relative 'rubocop/cop/style/rescue_modifier'
|
649
654
|
require_relative 'rubocop/cop/style/rescue_standard_error'
|
650
655
|
require_relative 'rubocop/cop/style/return_nil'
|
656
|
+
require_relative 'rubocop/cop/style/return_nil_in_predicate_method_definition'
|
651
657
|
require_relative 'rubocop/cop/style/safe_navigation'
|
652
658
|
require_relative 'rubocop/cop/style/sample'
|
653
659
|
require_relative 'rubocop/cop/style/select_by_regexp'
|
@@ -694,6 +700,7 @@ require_relative 'rubocop/cop/style/when_then'
|
|
694
700
|
require_relative 'rubocop/cop/style/while_until_do'
|
695
701
|
require_relative 'rubocop/cop/style/while_until_modifier'
|
696
702
|
require_relative 'rubocop/cop/style/word_array'
|
703
|
+
require_relative 'rubocop/cop/style/yaml_file_read'
|
697
704
|
require_relative 'rubocop/cop/style/yoda_condition'
|
698
705
|
require_relative 'rubocop/cop/style/yoda_expression'
|
699
706
|
require_relative 'rubocop/cop/style/zero_length_predicate'
|
@@ -739,6 +746,7 @@ require_relative 'rubocop/cli/command/base'
|
|
739
746
|
require_relative 'rubocop/cli/command/auto_generate_config'
|
740
747
|
require_relative 'rubocop/cli/command/execute_runner'
|
741
748
|
require_relative 'rubocop/cli/command/init_dotfile'
|
749
|
+
require_relative 'rubocop/cli/command/lsp'
|
742
750
|
require_relative 'rubocop/cli/command/show_cops'
|
743
751
|
require_relative 'rubocop/cli/command/show_docs_url'
|
744
752
|
require_relative 'rubocop/cli/command/suggest_extensions'
|
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.53.1
|
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: 2023-06-
|
13
|
+
date: 2023-06-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -26,6 +26,20 @@ dependencies:
|
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '2.3'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: language_server-protocol
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.17.0
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.17.0
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: parallel
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,6 +212,7 @@ files:
|
|
198
212
|
- lib/rubocop/cli/command/base.rb
|
199
213
|
- lib/rubocop/cli/command/execute_runner.rb
|
200
214
|
- lib/rubocop/cli/command/init_dotfile.rb
|
215
|
+
- lib/rubocop/cli/command/lsp.rb
|
201
216
|
- lib/rubocop/cli/command/show_cops.rb
|
202
217
|
- lib/rubocop/cli/command/show_docs_url.rb
|
203
218
|
- lib/rubocop/cli/command/suggest_extensions.rb
|
@@ -456,6 +471,7 @@ files:
|
|
456
471
|
- lib/rubocop/cop/lint/loop.rb
|
457
472
|
- lib/rubocop/cop/lint/missing_cop_enable_directive.rb
|
458
473
|
- lib/rubocop/cop/lint/missing_super.rb
|
474
|
+
- lib/rubocop/cop/lint/mixed_case_range.rb
|
459
475
|
- lib/rubocop/cop/lint/mixed_regexp_capture_types.rb
|
460
476
|
- lib/rubocop/cop/lint/multiple_comparison.rb
|
461
477
|
- lib/rubocop/cop/lint/nested_method_definition.rb
|
@@ -478,6 +494,7 @@ files:
|
|
478
494
|
- lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
|
479
495
|
- lib/rubocop/cop/lint/redundant_cop_enable_directive.rb
|
480
496
|
- lib/rubocop/cop/lint/redundant_dir_glob_sort.rb
|
497
|
+
- lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb
|
481
498
|
- lib/rubocop/cop/lint/redundant_require_statement.rb
|
482
499
|
- lib/rubocop/cop/lint/redundant_safe_navigation.rb
|
483
500
|
- lib/rubocop/cop/lint/redundant_splat_expansion.rb
|
@@ -823,6 +840,7 @@ files:
|
|
823
840
|
- lib/rubocop/cop/style/redundant_condition.rb
|
824
841
|
- lib/rubocop/cop/style/redundant_conditional.rb
|
825
842
|
- lib/rubocop/cop/style/redundant_constant_base.rb
|
843
|
+
- lib/rubocop/cop/style/redundant_current_directory_in_path.rb
|
826
844
|
- lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb
|
827
845
|
- lib/rubocop/cop/style/redundant_each.rb
|
828
846
|
- lib/rubocop/cop/style/redundant_exception.rb
|
@@ -836,6 +854,7 @@ files:
|
|
836
854
|
- lib/rubocop/cop/style/redundant_line_continuation.rb
|
837
855
|
- lib/rubocop/cop/style/redundant_parentheses.rb
|
838
856
|
- lib/rubocop/cop/style/redundant_percent_q.rb
|
857
|
+
- lib/rubocop/cop/style/redundant_regexp_argument.rb
|
839
858
|
- lib/rubocop/cop/style/redundant_regexp_character_class.rb
|
840
859
|
- lib/rubocop/cop/style/redundant_regexp_constructor.rb
|
841
860
|
- lib/rubocop/cop/style/redundant_regexp_escape.rb
|
@@ -851,6 +870,7 @@ files:
|
|
851
870
|
- lib/rubocop/cop/style/rescue_modifier.rb
|
852
871
|
- lib/rubocop/cop/style/rescue_standard_error.rb
|
853
872
|
- lib/rubocop/cop/style/return_nil.rb
|
873
|
+
- lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb
|
854
874
|
- lib/rubocop/cop/style/safe_navigation.rb
|
855
875
|
- lib/rubocop/cop/style/sample.rb
|
856
876
|
- lib/rubocop/cop/style/select_by_regexp.rb
|
@@ -899,12 +919,14 @@ files:
|
|
899
919
|
- lib/rubocop/cop/style/while_until_do.rb
|
900
920
|
- lib/rubocop/cop/style/while_until_modifier.rb
|
901
921
|
- lib/rubocop/cop/style/word_array.rb
|
922
|
+
- lib/rubocop/cop/style/yaml_file_read.rb
|
902
923
|
- lib/rubocop/cop/style/yoda_condition.rb
|
903
924
|
- lib/rubocop/cop/style/yoda_expression.rb
|
904
925
|
- lib/rubocop/cop/style/zero_length_predicate.rb
|
905
926
|
- lib/rubocop/cop/team.rb
|
906
927
|
- lib/rubocop/cop/util.rb
|
907
928
|
- lib/rubocop/cop/utils/format_string.rb
|
929
|
+
- lib/rubocop/cop/utils/regexp_ranges.rb
|
908
930
|
- lib/rubocop/cop/variable_force.rb
|
909
931
|
- lib/rubocop/cop/variable_force/assignment.rb
|
910
932
|
- lib/rubocop/cop/variable_force/branch.rb
|
@@ -949,6 +971,11 @@ files:
|
|
949
971
|
- lib/rubocop/formatter/text_util.rb
|
950
972
|
- lib/rubocop/formatter/worst_offenders_formatter.rb
|
951
973
|
- lib/rubocop/lockfile.rb
|
974
|
+
- lib/rubocop/lsp/logger.rb
|
975
|
+
- lib/rubocop/lsp/routes.rb
|
976
|
+
- lib/rubocop/lsp/runtime.rb
|
977
|
+
- lib/rubocop/lsp/server.rb
|
978
|
+
- lib/rubocop/lsp/severity.rb
|
952
979
|
- lib/rubocop/magic_comment.rb
|
953
980
|
- lib/rubocop/name_similarity.rb
|
954
981
|
- lib/rubocop/options.rb
|
@@ -996,7 +1023,7 @@ metadata:
|
|
996
1023
|
homepage_uri: https://rubocop.org/
|
997
1024
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
998
1025
|
source_code_uri: https://github.com/rubocop/rubocop/
|
999
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
1026
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.53/
|
1000
1027
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
1001
1028
|
rubygems_mfa_required: 'true'
|
1002
1029
|
post_install_message:
|