-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump rubocop from 1.55.1 to 1.56.0 #515
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.55.1 to 1.56.0. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v1.55.1...v1.56.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
|
gem compare --diff rubocop 1.55.1 1.56.0 Compared versions: ["1.55.1", "1.56.0"]
DIFFERENT files:
1.55.1->1.56.0:
* Added:
lib/rubocop/cop/bundler/duplicated_group.rb
--- /tmp/20230810-2520-dv3szm 2023-08-10 02:38:34.077830879 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/bundler/duplicated_group.rb 2023-08-10 02:38:33.829820857 +0000
@@ -0,0 +1,81 @@
+# frozen_string_literal: true
+
+module RuboCop
+ module Cop
+ module Bundler
+ # A Gem group, or a set of groups, should be listed only once in a Gemfile.
+ #
+ # @example
+ # # bad
+ # group :development do
+ # gem 'rubocop'
+ # end
+ #
+ # group :development do
+ # gem 'rubocop-rails'
+ # end
+ #
+ # # bad (same set of groups declared twice)
+ # group :development, :test do
+ # gem 'rubocop'
+ # end
+ #
+ # group :test, :development do
+ # gem 'rspec'
+ # end
+ #
+ # # good
+ # group :development do
+ # gem 'rubocop'
+ # end
+ #
+ # group :development, :test do
+ # gem 'rspec'
+ # end
+ #
+ # # good
+ # gem 'rubocop', groups: [:development, :test]
+ # gem 'rspec', groups: [:development, :test]
+ #
+ class DuplicatedGroup < Base
+ include RangeHelp
+
+ MSG = 'Gem group `%<group_name>s` already defined on line ' \
+ '%<line_of_first_occurrence>d of the Gemfile.'
+
+ def on_new_investigation
+ return if processed_source.blank?
+
+ duplicated_group_nodes.each do |nodes|
+ nodes[1..].each do |node|
+ register_offense(node, node.arguments.map(&:value).join(', '), nodes.first.first_line)
+ end
+ end
+ end
+
+ private
+
+ # @!method group_declarations(node)
+ def_node_search :group_declarations, '(send nil? :group ...)'
+
+ def duplicated_group_nodes
+ group_declarations(processed_source.ast)
+ .group_by { |node| node.arguments.map(&:value).map(&:to_s).sort }
+ .values
+ .select { |nodes| nodes.size > 1 }
+ end
+
+ def register_offense(node, group_name, line_of_first_occurrence)
+ line_range = node.loc.column...node.loc.last_column
+ offense_location = source_range(processed_source.buffer, node.first_line, line_range)
+ message = format(
+ MSG,
+ group_name: group_name,
+ line_of_first_occurrence: line_of_first_occurrence
+ )
+ add_offense(offense_location, message: message)
+ end
+ end
+ end
+ end
+end
* Changed:
README.md
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/README.md 2023-08-10 02:38:33.601811645 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/README.md 2023-08-10 02:38:33.821820534 +0000
@@ -56 +56 @@
-gem 'rubocop', '~> 1.55', require: false
+gem 'rubocop', '~> 1.56', require: false
config/default.yml
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/config/default.yml 2023-08-10 02:38:33.601811645 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/config/default.yml 2023-08-10 02:38:33.821820534 +0000
@@ -175,0 +176,10 @@
+Bundler/DuplicatedGroup:
+ Description: 'Checks for duplicate group entries in Gemfile.'
+ Enabled: true
+ Severity: warning
+ VersionAdded: '1.56'
+ Include:
+ - '**/*.gemfile'
+ - '**/Gemfile'
+ - '**/gems.rb'
+
lib/rubocop.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop.rb 2023-08-10 02:38:33.601811645 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop.rb 2023-08-10 02:38:33.821820534 +0000
@@ -164,0 +165 @@
+require_relative 'rubocop/cop/bundler/duplicated_group'
lib/rubocop/config_finder.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/config_finder.rb 2023-08-10 02:38:33.605811806 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/config_finder.rb 2023-08-10 02:38:33.825820696 +0000
@@ -49 +49 @@
- return file if File.exist?(file)
+ file if File.exist?(file)
@@ -56 +56 @@
- return xdg_config if File.exist?(xdg_config)
+ xdg_config if File.exist?(xdg_config)
lib/rubocop/cop/bundler/duplicated_gem.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/bundler/duplicated_gem.rb 2023-08-10 02:38:33.609811968 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/bundler/duplicated_gem.rb 2023-08-10 02:38:33.829820857 +0000
@@ -6,0 +7 @@
+ #
lib/rubocop/cop/layout/empty_line_after_guard_clause.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb 2023-08-10 02:38:33.617812291 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb 2023-08-10 02:38:33.841821342 +0000
@@ -140 +140 @@
- return last_heredoc_argument(n.receiver) if n.respond_to?(:receiver)
+ last_heredoc_argument(n.receiver) if n.respond_to?(:receiver)
lib/rubocop/cop/layout/indentation_width.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/layout/indentation_width.rb 2023-08-10 02:38:33.621812453 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/layout/indentation_width.rb 2023-08-10 02:38:33.845821504 +0000
@@ -357 +357 @@
- return true unless body_node.loc.column == first_char_pos_on_line
+ true unless body_node.loc.column == first_char_pos_on_line
lib/rubocop/cop/layout/space_inside_parens.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/layout/space_inside_parens.rb 2023-08-10 02:38:33.629812776 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/layout/space_inside_parens.rb 2023-08-10 02:38:33.849821666 +0000
@@ -171 +171 @@
- return true unless same_line?(token1, token2) && !token1.space_after?
+ true unless same_line?(token1, token2) && !token1.space_after?
lib/rubocop/cop/lint/struct_new_override.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/lint/struct_new_override.rb 2023-08-10 02:38:33.645813422 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/lint/struct_new_override.rb 2023-08-10 02:38:33.865822312 +0000
@@ -35 +35 @@
- (const ${nil? cbase} :Struct) :new ...)
+ (const {nil? cbase} :Struct) :new ...)
@@ -39,4 +39 @@
- return unless struct_new(node) do
- node.arguments.each_with_index do |arg, index|
- # Ignore if the first argument is a class name
- next if index.zero? && arg.str_type?
+ return unless struct_new(node)
@@ -44,2 +41,3 @@
- # Ignore if the argument is not a member name
- next unless STRUCT_MEMBER_NAME_TYPES.include?(arg.type)
+ node.arguments.each_with_index do |arg, index|
+ # Ignore if the first argument is a class name
+ next if index.zero? && arg.str_type?
@@ -47 +45,2 @@
- member_name = arg.value
+ # Ignore if the argument is not a member name
+ next unless STRUCT_MEMBER_NAME_TYPES.include?(arg.type)
@@ -49 +48 @@
- next unless STRUCT_METHOD_NAMES.include?(member_name.to_sym)
+ member_name = arg.value
@@ -51,3 +50,4 @@
- message = format(MSG, member_name: member_name.inspect, method_name: member_name.to_s)
- add_offense(arg, message: message)
- end
+ next unless STRUCT_METHOD_NAMES.include?(member_name.to_sym)
+
+ message = format(MSG, member_name: member_name.inspect, method_name: member_name.to_s)
+ add_offense(arg, message: message)
lib/rubocop/cop/lint/suppressed_exception.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/lint/suppressed_exception.rb 2023-08-10 02:38:33.645813422 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/lint/suppressed_exception.rb 2023-08-10 02:38:33.865822312 +0000
@@ -122 +122 @@
- end_line = ancestor.loc.end.line
+ end_line = ancestor.loc.end&.line || ancestor.loc.last_line
lib/rubocop/cop/mixin/string_help.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/mixin/string_help.rb 2023-08-10 02:38:33.657813907 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/mixin/string_help.rb 2023-08-10 02:38:33.981826999 +0000
@@ -33,2 +33,4 @@
- # A :begin node inside a :dstr or :dsym node is an interpolation.
- node.ancestors.drop_while { |a| !a.begin_type? }.any? { |a| a.dstr_type? || a.dsym_type? }
+ # A :begin node inside a :dstr, :dsym, or :regexp node is an interpolation.
+ node.ancestors
+ .drop_while { |a| !a.begin_type? }
+ .any? { |a| a.dstr_type? || a.dsym_type? || a.regexp_type? }
lib/rubocop/cop/style/alias.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/alias.rb 2023-08-10 02:38:33.661814069 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/alias.rb 2023-08-10 02:38:34.021828616 +0000
@@ -125 +125 @@
- !sym_node.source.start_with?(':')
+ !sym_node.source.start_with?(':') || sym_node.dsym_type?
@@ -137,3 +137 @@
- 'alias_method ' \
- ":#{identifier(node.new_identifier)}, " \
- ":#{identifier(node.old_identifier)}"
+ "alias_method #{identifier(node.new_identifier)}, #{identifier(node.old_identifier)}"
@@ -149,4 +147,7 @@
- # @!method identifier(node)
- def_node_matcher :identifier, <<~PATTERN
- (sym $_)
- PATTERN
+ def identifier(node)
+ if node.sym_type?
+ ":#{node.children.first}"
+ else
+ node.source
+ end
+ end
lib/rubocop/cop/style/arguments_forwarding.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/arguments_forwarding.rb 2023-08-10 02:38:33.661814069 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/arguments_forwarding.rb 2023-08-10 02:38:34.021828616 +0000
@@ -103 +103 @@
- add_forward_all_offenses(node, send_classifications)
+ add_forward_all_offenses(node, send_classifications, forwardable_args)
@@ -121,3 +121,3 @@
- def add_forward_all_offenses(node, send_classifications)
- send_classifications.each_key do |send_node|
- register_forward_all_offense_on_forwarding_method(send_node)
+ def add_forward_all_offenses(node, send_classifications, forwardable_args)
+ send_classifications.each do |send_node, (_c, forward_rest, _forward_kwrest)|
+ register_forward_all_offense(send_node, send_node, forward_rest)
@@ -126 +126,2 @@
- register_forward_all_offense_on_method_def(node)
+ rest_arg, _kwrest_arg, _block_arg = *forwardable_args
+ register_forward_all_offense(node, node.arguments, rest_arg)
@@ -189,3 +190 @@
- unless parentheses?(def_arguments_or_send)
- add_parentheses(def_arguments_or_send, corrector)
- end
+ add_parens_if_missing(def_arguments_or_send, corrector)
@@ -199,3 +198 @@
- if add_parens && !parentheses?(def_arguments_or_send)
- add_parentheses(def_arguments_or_send, corrector)
- end
+ add_parens_if_missing(def_arguments_or_send, corrector) if add_parens
@@ -207,4 +204,2 @@
- def register_forward_all_offense_on_forwarding_method(forwarding_method)
- add_offense(arguments_range(forwarding_method), message: FORWARDING_MSG) do |corrector|
- begin_pos = forwarding_method.loc.selector&.end_pos || forwarding_method.loc.dot.end_pos
- range = range_between(begin_pos, forwarding_method.source_range.end_pos)
+ def register_forward_all_offense(def_or_send, send_or_arguments, rest_or_splat)
+ arg_range = arguments_range(def_or_send, rest_or_splat)
@@ -212,3 +207,2 @@
- corrector.replace(range, '(...)')
- end
- end
+ add_offense(arg_range, message: FORWARDING_MSG) do |corrector|
+ add_parens_if_missing(send_or_arguments, corrector)
@@ -216,6 +210 @@
- def register_forward_all_offense_on_method_def(method_definition)
- add_offense(arguments_range(method_definition), message: FORWARDING_MSG) do |corrector|
- arguments_range = range_with_surrounding_space(
- method_definition.arguments.source_range, side: :left
- )
- corrector.replace(arguments_range, '(...)')
+ corrector.replace(arg_range, '...')
@@ -225 +214 @@
- def arguments_range(node)
+ def arguments_range(node, first_node)
@@ -228 +217,3 @@
- range_between(arguments.first.source_range.begin_pos, arguments.last.source_range.end_pos)
+ start_node = first_node || arguments.first
+
+ range_between(start_node.source_range.begin_pos, arguments.last.source_range.end_pos)
@@ -238,0 +230,6 @@
+ def add_parens_if_missing(node, corrector)
+ return if parentheses?(node)
+
+ add_parentheses(node, corrector)
+ end
+
@@ -283 +280 @@
- if referenced_none? && (forwarded_exactly_all? || pre_ruby_32_allow_forward_all?)
+ if can_forward_all?
@@ -291,0 +289,21 @@
+ def can_forward_all?
+ return false if any_arg_referenced?
+ return false if ruby_32_missing_rest_or_kwest?
+ return false unless offensive_block_forwarding?
+ return false if forward_additional_kwargs?
+
+ no_additional_args? || (target_ruby_version >= 3.0 && no_post_splat_args?)
+ end
+
+ def ruby_32_missing_rest_or_kwest?
+ target_ruby_version >= 3.2 && !forwarded_rest_and_kwrest_args
+ end
+
+ def offensive_block_forwarding?
+ @block_arg ? forwarded_block_arg : allow_offense_for_no_block?
+ end
+
+ def forwarded_rest_and_kwrest_args
+ forwarded_rest_arg && forwarded_kwrest_arg
+ end
+
@@ -308,9 +326,2 @@
- def referenced_none?
- !(referenced_rest_arg? || referenced_kwrest_arg? || referenced_block_arg?)
- end
-
- def forwarded_exactly_all?
- @send_node.arguments.size == 3 &&
- forwarded_rest_arg &&
- forwarded_kwrest_arg &&
- forwarded_block_arg
+ def any_arg_referenced?
+ referenced_rest_arg? || referenced_kwrest_arg? || referenced_block_arg?
@@ -323,4 +334,22 @@
- def pre_ruby_32_allow_forward_all?
- target_ruby_version < 3.2 &&
- @def_node.arguments.none?(&:default?) &&
- (@block_arg ? forwarded_block_arg : [email protected](:allow_only_rest_arguments))
+ def no_post_splat_args?
+ splat_index = arguments.index(forwarded_rest_arg)
+ arg_after_splat = arguments[splat_index + 1]
+
+ [nil, :hash, :block_pass].include?(arg_after_splat&.type)
+ end
+
+ def forward_additional_kwargs?
+ return false unless forwarded_kwrest_arg
+
+ !forwarded_kwrest_arg.parent.children.one?
+ end
+
+ def allow_offense_for_no_block?
+ [email protected](:allow_only_rest_arguments)
+ end
+
+ def no_additional_args?
+ forwardable_count = [@rest_arg, @kwrest_arg, @block_arg].compact.size
+
+ @def_node.arguments.size == forwardable_count &&
+ @send_node.arguments.size == forwardable_count
lib/rubocop/cop/style/block_delimiters.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/block_delimiters.rb 2023-08-10 02:38:33.665814231 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/block_delimiters.rb 2023-08-10 02:38:34.021828616 +0000
@@ -373 +373,2 @@
- return node.braces? if braces_required_method?(method_name)
+
+ node.braces? if braces_required_method?(method_name)
lib/rubocop/cop/style/class_equality_comparison.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/class_equality_comparison.rb 2023-08-10 02:38:33.665814231 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/class_equality_comparison.rb 2023-08-10 02:38:34.021828616 +0000
@@ -71,0 +72,2 @@
+ return if class_node.dstr_type?
+
lib/rubocop/cop/style/lambda_call.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/lambda_call.rb 2023-08-10 02:38:33.785819080 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/lambda_call.rb 2023-08-10 02:38:34.033829101 +0000
@@ -22,0 +23 @@
+ include IgnoredNode
@@ -35,0 +37,2 @@
+ next if part_of_ignored_node?(node)
+
@@ -37,0 +41,2 @@
+
+ ignore_node(node)
lib/rubocop/cop/style/redundant_return.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/redundant_return.rb 2023-08-10 02:38:33.797819564 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/redundant_return.rb 2023-08-10 02:38:34.049829747 +0000
@@ -25 +25 @@
- # # good
+ # # bad
@@ -31,0 +32,5 @@
+ # something if something_else
+ # end
+ #
+ # # good
+ # def test
@@ -139 +144 @@
- return if node.modifier_form? || node.ternary?
+ return if node.ternary?
lib/rubocop/cop/style/string_literals_in_interpolation.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/string_literals_in_interpolation.rb 2023-08-10 02:38:33.801819726 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/string_literals_in_interpolation.rb 2023-08-10 02:38:34.057830070 +0000
@@ -6 +6 @@
- # Checks that quotes inside the string interpolation
+ # Checks that quotes inside string, symbol, and regexp interpolations
@@ -11 +11,6 @@
- # result = "Tests #{success ? "PASS" : "FAIL"}"
+ # string = "Tests #{success ? "PASS" : "FAIL"}"
+ # symbol = :"Tests #{success ? "PASS" : "FAIL"}"
+ # heredoc = <<~TEXT
+ # Tests #{success ? "PASS" : "FAIL"}
+ # TEXT
+ # regexp = /Tests #{success ? "PASS" : "FAIL"}/
@@ -14 +19,6 @@
- # result = "Tests #{success ? 'PASS' : 'FAIL'}"
+ # string = "Tests #{success ? 'PASS' : 'FAIL'}"
+ # symbol = :"Tests #{success ? 'PASS' : 'FAIL'}"
+ # heredoc = <<~TEXT
+ # Tests #{success ? 'PASS' : 'FAIL'}
+ # TEXT
+ # regexp = /Tests #{success ? 'PASS' : 'FAIL'}/
@@ -18 +28,6 @@
- # result = "Tests #{success ? 'PASS' : 'FAIL'}"
+ # string = "Tests #{success ? 'PASS' : 'FAIL'}"
+ # symbol = :"Tests #{success ? 'PASS' : 'FAIL'}"
+ # heredoc = <<~TEXT
+ # Tests #{success ? 'PASS' : 'FAIL'}
+ # TEXT
+ # regexp = /Tests #{success ? 'PASS' : 'FAIL'}/
@@ -21 +36,6 @@
- # result = "Tests #{success ? "PASS" : "FAIL"}"
+ # string = "Tests #{success ? "PASS" : "FAIL"}"
+ # symbol = :"Tests #{success ? "PASS" : "FAIL"}"
+ # heredoc = <<~TEXT
+ # Tests #{success ? "PASS" : "FAIL"}
+ # TEXT
+ # regexp = /Tests #{success ? "PASS" : "FAIL"}/
@@ -30,0 +51,5 @@
+
+ # Cop classes that include the StringHelp module usually ignore regexp
+ # nodes. Not so for this cop, which is why we override the on_regexp
+ # definition with an empty one.
+ def on_regexp(node); end
lib/rubocop/cop/style/symbol_array.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/cop/style/symbol_array.rb 2023-08-10 02:38:33.805819888 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/cop/style/symbol_array.rb 2023-08-10 02:38:34.057830070 +0000
@@ -72,3 +72,3 @@
- content, = *sym
- content = content.to_s
- content_without_delimiter_pairs = content.gsub(/(\[\])|(\(\))/, '')
+ content = *sym
+ content = content.map { |c| c.is_a?(AST::Node) ? c.source : c }.join
+ content_without_delimiter_pairs = content.gsub(/(\[[^\s\[\]]*\])|(\([^\s\(\)]*\))/, '')
lib/rubocop/lsp/routes.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/lsp/routes.rb 2023-08-10 02:38:33.813820211 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/lsp/routes.rb 2023-08-10 02:38:34.069830555 +0000
@@ -115,14 +115,5 @@
- if request[:params][:command] == 'rubocop.formatAutocorrects'
- uri = request[:params][:arguments][0][:uri]
- @server.write(
- id: request[:id],
- method: 'workspace/applyEdit',
- params: {
- label: 'Format with RuboCop autocorrects',
- edit: {
- changes: {
- uri => format_file(uri)
- }
- }
- }
- )
+ case (command = request[:params][:command])
+ when 'rubocop.formatAutocorrects'
+ label = 'Format with RuboCop autocorrects'
+ when 'rubocop.formatAutocorrectsAll'
+ label = 'Format all with RuboCop autocorrects'
@@ -130 +121,2 @@
- handle_unsupported_method(request, request[:params][:command])
+ handle_unsupported_method(request, command)
+ return
@@ -131,0 +124,14 @@
+
+ uri = request[:params][:arguments][0][:uri]
+ @server.write(
+ id: request[:id],
+ method: 'workspace/applyEdit',
+ params: {
+ label: label,
+ edit: {
+ changes: {
+ uri => format_file(uri, command: command)
+ }
+ }
+ }
+ )
@@ -179 +185 @@
- def format_file(file_uri)
+ def format_file(file_uri, command: nil)
@@ -186 +192 @@
- new_text = @server.format(remove_file_protocol_from(file_uri), text)
+ new_text = @server.format(remove_file_protocol_from(file_uri), text, command: command)
lib/rubocop/lsp/runtime.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/lsp/runtime.rb 2023-08-10 02:38:33.813820211 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/lsp/runtime.rb 2023-08-10 02:38:34.069830555 +0000
@@ -38 +38,7 @@
- def format(path, text)
+ def format(path, text, command:)
+ safe_autocorrect = if command
+ command == 'rubocop.formatAutocorrects'
+ else
+ @safe_autocorrect
+ end
+
@@ -40 +46 @@
- stdin: text, force_exclusion: true, autocorrect: true, safe_autocorrect: @safe_autocorrect
+ stdin: text, force_exclusion: true, autocorrect: true, safe_autocorrect: safe_autocorrect
lib/rubocop/lsp/server.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/lsp/server.rb 2023-08-10 02:38:33.813820211 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/lsp/server.rb 2023-08-10 02:38:34.069830555 +0000
@@ -48,2 +48,2 @@
- def format(path, text)
- @runtime.format(path, text)
+ def format(path, text, command:)
+ @runtime.format(path, text, command: command)
lib/rubocop/runner.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/runner.rb 2023-08-10 02:38:33.817820373 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/runner.rb 2023-08-10 02:38:34.073830717 +0000
@@ -424 +423,0 @@
- # For :autocorrect level, any offense - corrected or not - is a failure.
@@ -427 +426,2 @@
- return true if @options[:fail_level] == :autocorrect
+ # For :autocorrect level, any correctable offense is a failure, regardless of severity
+ return true if @options[:fail_level] == :autocorrect && offense.correctable?
@@ -464 +464,3 @@
- RuboCop::Cop::Severity.new(name)
+
+ # autocorrect is a fake level - use the default
+ RuboCop::Cop::Severity.new(name == :autocorrect ? :refactor : name)
lib/rubocop/version.rb
--- /tmp/d20230810-2520-o6sl7t/rubocop-1.55.1/lib/rubocop/version.rb 2023-08-10 02:38:33.821820534 +0000
+++ /tmp/d20230810-2520-o6sl7t/rubocop-1.56.0/lib/rubocop/version.rb 2023-08-10 02:38:34.077830879 +0000
@@ -6 +6 @@
- STRING = '1.55.1'
+ STRING = '1.56.0'
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bumps rubocop from 1.55.1 to 1.56.0.
Release notes
Sourced from rubocop's releases.
Changelog
Sourced from rubocop's changelog.
Commits
e597ca1
Cut 1.563036b2c
Tweak whitespace74f0032
Update Changelog964235c
Add newBundler/DuplicatedGroup
cop (#12074)c078235
With--fail-level A
ignore non-correctable offenses at :info severity320ac56
Merge pull request #12103 from owst/fixup_additional_args_forwarding08e614f
[Fix #12087] Fix false positives for Style/ArgumentsForwardingf871c38
[Fix #12106] Fix a false negative forStyle/RedundantReturn
235f749
Merge pull request #12102 from koic/fix_an_error_for_style_lambda_call57dd392
Fix an error forStyle/LambdaCall
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditions
will show all of the ignore conditions of the specified dependency@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)