-
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.68.0 to 1.69.0 #691
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
gem compare json 2.7.5 2.8.2 Compared versions: ["2.7.5", "2.8.2"]
DIFFERENT date:
2.7.5: 2024-10-30 00:00:00 UTC
2.8.2: 2024-11-14 00:00:00 UTC
DIFFERENT require_paths:
2.7.5: ["/opt/hostedtoolcache/Ruby/3.3.6/x64/lib/ruby/gems/3.3.0/extensions/x86_64-linux/3.3.0/json-2.7.5", "lib"]
2.8.2: ["/opt/hostedtoolcache/Ruby/3.3.6/x64/lib/ruby/gems/3.3.0/extensions/x86_64-linux/3.3.0/json-2.8.2", "lib"]
DIFFERENT required_ruby_version:
2.7.5: >= 2.3
2.8.2: >= 2.7
DIFFERENT version:
2.7.5: 2.7.5
2.8.2: 2.8.2
DIFFERENT files:
2.7.5->2.8.2:
* Deleted:
ext/json/ext/generator/generator.h
ext/json/ext/parser/parser.h
lib/json/pure.rb
lib/json/pure/generator.rb
lib/json/pure/parser.rb
* Added:
lib/json/truffle_ruby/generator.rb +621/-0
* Changed:
CHANGES.md +23/-0
README.md +8/-77
ext/json/ext/fbuffer/fbuffer.h +85/-47
ext/json/ext/generator/generator.c +335/-204
ext/json/ext/parser/extconf.rb +5/-27
ext/json/ext/parser/parser.c +1594/-593
ext/json/ext/parser/parser.rl +729/-261
json.gemspec +4/-1
lib/json.rb +15/-20
lib/json/add/bigdecimal.rb +1/-1
lib/json/common.rb +206/-64
lib/json/ext.rb +2/-4
lib/json/ext/generator/state.rb +1/-31
lib/json/version.rb +1/-1
DIFFERENT extra_rdoc_files:
2.7.5->2.8.2:
* Changed:
README.md +8/-77 |
|
gem compare parser 3.3.5.1 3.3.6.0 Compared versions: ["3.3.5.1", "3.3.6.0"]
DIFFERENT date:
3.3.5.1: 2024-10-31 00:00:00 UTC
3.3.6.0: 2024-11-05 00:00:00 UTC
DIFFERENT metadata:
3.3.5.1: {"bug_tracker_uri"=>"https://github.com/whitequark/parser/issues", "changelog_uri"=>"https://github.com/whitequark/parser/blob/v3.3.5.1/CHANGELOG.md", "documentation_uri"=>"https://www.rubydoc.info/gems/parser/3.3.5.1", "source_code_uri"=>"https://github.com/whitequark/parser/tree/v3.3.5.1"}
3.3.6.0: {"bug_tracker_uri"=>"https://github.com/whitequark/parser/issues", "changelog_uri"=>"https://github.com/whitequark/parser/blob/v3.3.6.0/CHANGELOG.md", "documentation_uri"=>"https://www.rubydoc.info/gems/parser/3.3.6.0", "source_code_uri"=>"https://github.com/whitequark/parser/tree/v3.3.6.0"}
DIFFERENT version:
3.3.5.1: 3.3.5.1
3.3.6.0: 3.3.6.0
DIFFERENT files:
3.3.5.1->3.3.6.0:
* Changed:
lib/parser/current.rb +1/-1
lib/parser/version.rb +1/-1 |
gem compare --diff parser 3.3.5.1 3.3.6.0 Compared versions: ["3.3.5.1", "3.3.6.0"]
DIFFERENT files:
3.3.5.1->3.3.6.0:
* Changed:
lib/parser/current.rb
--- /tmp/d20241127-2426-2l5x83/parser-3.3.5.1/lib/parser/current.rb 2024-11-27 03:31:08.513156550 +0000
+++ /tmp/d20241127-2426-2l5x83/parser-3.3.6.0/lib/parser/current.rb 2024-11-27 03:31:08.657157420 +0000
@@ -114 +114 @@
- current_version = '3.3.5'
+ current_version = '3.3.6'
lib/parser/version.rb
--- /tmp/d20241127-2426-2l5x83/parser-3.3.5.1/lib/parser/version.rb 2024-11-27 03:31:08.653157396 +0000
+++ /tmp/d20241127-2426-2l5x83/parser-3.3.6.0/lib/parser/version.rb 2024-11-27 03:31:08.737157904 +0000
@@ -4 +4 @@
- VERSION = '3.3.5.1'
+ VERSION = '3.3.6.0' |
gem compare rubocop 1.68.0 1.69.0 Compared versions: ["1.68.0", "1.69.0"]
DIFFERENT date:
1.68.0: 2024-10-31 00:00:00 UTC
1.69.0: 2024-11-26 00:00:00 UTC
DIFFERENT metadata:
1.68.0: {"homepage_uri"=>"https://rubocop.org/", "changelog_uri"=>"https://github.com/rubocop/rubocop/releases/tag/v1.68.0", "source_code_uri"=>"https://github.com/rubocop/rubocop/", "documentation_uri"=>"https://docs.rubocop.org/rubocop/1.68/", "bug_tracker_uri"=>"https://github.com/rubocop/rubocop/issues", "rubygems_mfa_required"=>"true"}
1.69.0: {"homepage_uri"=>"https://rubocop.org/", "changelog_uri"=>"https://github.com/rubocop/rubocop/releases/tag/v1.69.0", "source_code_uri"=>"https://github.com/rubocop/rubocop/", "documentation_uri"=>"https://docs.rubocop.org/rubocop/1.69/", "bug_tracker_uri"=>"https://github.com/rubocop/rubocop/issues", "rubygems_mfa_required"=>"true"}
DIFFERENT version:
1.68.0: 1.68.0
1.69.0: 1.69.0
DIFFERENT files:
1.68.0->1.69.0:
* Added:
lib/rubocop/cop/internal_affairs/operator_keyword.rb +46/-0
lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb +55/-0
lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +106/-0
lib/rubocop/cop/lint/useless_defined.rb +55/-0
lib/rubocop/cop/mixin/check_single_line_suitability.rb +49/-0
lib/rubocop/cop/mixin/dig_help.rb +27/-0
lib/rubocop/cop/style/dig_chain.rb +90/-0
lib/rubocop/cop/style/file_null.rb +73/-0
lib/rubocop/cop/style/file_touch.rb +75/-0
* Changed:
README.md +1/-1
config/default.yml +41/-6
lib/rubocop.rb +8/-0
lib/rubocop/cop/base.rb +1/-1
lib/rubocop/cop/bundler/gem_filename.rb +0/-1
lib/rubocop/cop/bundler/insecure_protocol_source.rb +0/-1
lib/rubocop/cop/correctors/for_to_each_corrector.rb +1/-1
lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1/-2
lib/rubocop/cop/gemspec/required_ruby_version.rb +0/-2
lib/rubocop/cop/internal_affairs.rb +1/-0
lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +2/-4
lib/rubocop/cop/internal_affairs/numblock_handler.rb +1/-1
lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +0/-2
lib/rubocop/cop/layout/argument_alignment.rb +1/-2
lib/rubocop/cop/layout/array_alignment.rb +1/-1
lib/rubocop/cop/layout/begin_end_alignment.rb +0/-1
lib/rubocop/cop/layout/block_alignment.rb +1/-2
lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1/-1
lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2/-3
lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +3/-4
lib/rubocop/cop/layout/empty_lines_around_method_body.rb +3/-1
lib/rubocop/cop/layout/indentation_width.rb +7/-7
lib/rubocop/cop/layout/leading_comment_space.rb +15/-0
lib/rubocop/cop/layout/line_length.rb +118/-4
lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1/-1
lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1/-1
lib/rubocop/cop/layout/multiline_operation_indentation.rb +2/-3
lib/rubocop/cop/layout/parameter_alignment.rb +3/-4
lib/rubocop/cop/layout/redundant_line_break.rb +3/-35
lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3/-2
lib/rubocop/cop/layout/space_around_keyword.rb +1/-1
lib/rubocop/cop/layout/space_around_operators.rb +16/-17
lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +6/-0
lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +4/-0
lib/rubocop/cop/layout/space_inside_string_interpolation.rb +0/-1
lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +11/-12
lib/rubocop/cop/lint/circular_argument_reference.rb +2/-0
lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1/-1
lib/rubocop/cop/lint/empty_ensure.rb +1/-1
lib/rubocop/cop/lint/empty_file.rb +0/-2
lib/rubocop/cop/lint/ensure_return.rb +1/-1
lib/rubocop/cop/lint/float_comparison.rb +14/-6
lib/rubocop/cop/lint/float_out_of_range.rb +1/-3
lib/rubocop/cop/lint/interpolation_check.rb +9/-0
lib/rubocop/cop/lint/it_without_arguments_in_block.rb +3/-0
lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1/-1
lib/rubocop/cop/lint/mixed_case_range.rb +2/-5
lib/rubocop/cop/lint/nested_method_definition.rb +1/-1
lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +2/-2
lib/rubocop/cop/lint/non_atomic_file_operation.rb +1/-1
lib/rubocop/cop/lint/number_conversion.rb +0/-1
lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1/-2
lib/rubocop/cop/lint/or_assignment_to_constant.rb +1/-2
lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +1/-1
lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1/-1
lib/rubocop/cop/lint/redundant_safe_navigation.rb +12/-7
lib/rubocop/cop/lint/redundant_splat_expansion.rb +8/-7
lib/rubocop/cop/lint/regexp_as_condition.rb +0/-1
lib/rubocop/cop/lint/rescue_type.rb +3/-7
lib/rubocop/cop/lint/safe_navigation_consistency.rb +2/-0
lib/rubocop/cop/lint/self_assignment.rb +8/-10
lib/rubocop/cop/lint/shadowed_exception.rb +1/-1
lib/rubocop/cop/lint/unused_method_argument.rb +18/-2
lib/rubocop/cop/lint/useless_rescue.rb +1/-1
lib/rubocop/cop/lint/useless_setter_call.rb +14/-25
lib/rubocop/cop/lint/void.rb +3/-2
lib/rubocop/cop/metrics/class_length.rb +7/-7
lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1/-1
lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1/-2
lib/rubocop/cop/mixin/check_assignment.rb +4/-12
lib/rubocop/cop/mixin/multiline_expression_indentation.rb +5/-9
lib/rubocop/cop/mixin/range_help.rb +0/-1
lib/rubocop/cop/mixin/target_ruby_version.rb +17/-1
lib/rubocop/cop/naming/constant_name.rb +6/-7
lib/rubocop/cop/naming/file_name.rb +0/-2
lib/rubocop/cop/naming/memoized_instance_variable_name.rb +11/-12
lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +3/-11
lib/rubocop/cop/naming/variable_name.rb +3/-4
lib/rubocop/cop/naming/variable_number.rb +2/-3
lib/rubocop/cop/style/access_modifier_declarations.rb +53/-24
lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +1/-1
lib/rubocop/cop/style/array_intersect.rb +5/-4
lib/rubocop/cop/style/bitwise_predicate.rb +1/-1
lib/rubocop/cop/style/block_delimiters.rb +1/-1
lib/rubocop/cop/style/case_like_if.rb +8/-11
lib/rubocop/cop/style/commented_keyword.rb +11/-1
lib/rubocop/cop/style/conditional_assignment.rb +19/-21
lib/rubocop/cop/style/constant_visibility.rb +3/-12
lib/rubocop/cop/style/for.rb +0/-1
lib/rubocop/cop/style/global_vars.rb +1/-3
lib/rubocop/cop/style/guard_clause.rb +1/-1
lib/rubocop/cop/style/hash_conversion.rb +1/-2
lib/rubocop/cop/style/if_inside_else.rb +0/-1
lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +1/-2
lib/rubocop/cop/style/if_with_semicolon.rb +14/-5
lib/rubocop/cop/style/inverse_methods.rb +0/-1
lib/rubocop/cop/style/keyword_arguments_merging.rb +2/-2
lib/rubocop/cop/style/lambda_call.rb +0/-1
lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +1/-1
lib/rubocop/cop/style/method_call_without_args_parentheses.rb +7/-11
lib/rubocop/cop/style/missing_respond_to_missing.rb +33/-3
lib/rubocop/cop/style/multiline_memoization.rb +1/-1
lib/rubocop/cop/style/mutable_constant.rb +4/-5
lib/rubocop/cop/style/negated_if_else_condition.rb +6/-4
lib/rubocop/cop/style/nested_ternary_operator.rb +5/-4
lib/rubocop/cop/style/not.rb +1/-1
lib/rubocop/cop/style/one_line_conditional.rb +25/-4
lib/rubocop/cop/style/operator_method_call.rb +5/-6
lib/rubocop/cop/style/or_assignment.rb +3/-6
lib/rubocop/cop/style/parallel_assignment.rb +8/-13
lib/rubocop/cop/style/raise_args.rb +1/-1
lib/rubocop/cop/style/redundant_assignment.rb +1/-1
lib/rubocop/cop/style/redundant_condition.rb +36/-21
lib/rubocop/cop/style/redundant_line_continuation.rb +7/-6
lib/rubocop/cop/style/redundant_parentheses.rb +1/-1
lib/rubocop/cop/style/redundant_regexp_argument.rb +1/-0
lib/rubocop/cop/style/redundant_return.rb +2/-2
lib/rubocop/cop/style/redundant_self.rb +7/-14
lib/rubocop/cop/style/redundant_self_assignment.rb +7/-5
lib/rubocop/cop/style/redundant_self_assignment_branch.rb +4/-4
lib/rubocop/cop/style/redundant_sort.rb +1/-1
lib/rubocop/cop/style/rescue_modifier.rb +2/-3
lib/rubocop/cop/style/safe_navigation.rb +1/-1
lib/rubocop/cop/style/select_by_regexp.rb +1/-1
lib/rubocop/cop/style/self_assignment.rb +11/-17
lib/rubocop/cop/style/signal_exception.rb +2/-3
lib/rubocop/cop/style/single_argument_dig.rb +9/-5
lib/rubocop/cop/style/single_line_do_end_block.rb +13/-3
lib/rubocop/cop/style/sole_nested_conditional.rb +2/-3
lib/rubocop/cop/style/special_global_vars.rb +1/-1
lib/rubocop/cop/style/string_concatenation.rb +0/-1
lib/rubocop/cop/style/swap_values.rb +4/-15
lib/rubocop/cop/style/trailing_underscore_variable.rb +4/-4
lib/rubocop/cop/style/variable_interpolation.rb +1/-2
lib/rubocop/cop/variable_force.rb +4/-10
lib/rubocop/cops_documentation_generator.rb +9/-1
lib/rubocop/version.rb +1/-1
DIFFERENT extra_rdoc_files:
1.68.0->1.69.0:
* Changed:
README.md +1/-1
DIFFERENT runtime dependencies:
1.68.0->1.69.0:
* Updated:
rubocop-ast from: [">= 1.32.2", "< 2.0"] to: [">= 1.36.1", "< 2.0"]
unicode-display_width from: [">= 2.4.0", "< 3.0"] to: [">= 2.4.0", "< 4.0"] |
|
gem compare rubocop-ast 1.33.1 1.36.1 Compared versions: ["1.33.1", "1.36.1"]
DIFFERENT date:
1.33.1: 2024-11-02 00:00:00 UTC
1.36.1: 2024-11-13 00:00:00 UTC
DIFFERENT version:
1.33.1: 1.33.1
1.36.1: 1.36.1
DIFFERENT files:
1.33.1->1.36.1:
* Added:
lib/rubocop/ast/node/keyword_begin_node.rb +44/-0
* Changed:
lib/rubocop/ast.rb +1/-0
lib/rubocop/ast/builder.rb +1/-0
lib/rubocop/ast/node.rb +46/-9
lib/rubocop/ast/node/asgn_node.rb +2/-0
lib/rubocop/ast/node/casgn_node.rb +2/-0
lib/rubocop/ast/node/ensure_node.rb +15/-0
lib/rubocop/ast/node/op_asgn_node.rb +3/-1
lib/rubocop/ast/version.rb +1/-1 |
gem compare --diff rubocop-ast 1.33.1 1.36.1 Compared versions: ["1.33.1", "1.36.1"]
DIFFERENT files:
1.33.1->1.36.1:
* Added:
lib/rubocop/ast/node/keyword_begin_node.rb
--- /tmp/20241127-10126-z2qz1f 2024-11-27 03:31:59.305454448 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/node/keyword_begin_node.rb 2024-11-27 03:31:59.293454381 +0000
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+module RuboCop
+ module AST
+ # A node extension for `kwbegin` nodes. This will be used in place of a plain
+ # node when the builder constructs the AST, making its methods available
+ # to all `kwbegin` nodes within RuboCop.
+ class KeywordBeginNode < Node
+ # Returns the body of the `kwbegin` block. Returns `self` if the `kwbegin` contains
+ # multiple nodes.
+ #
+ # @return [Node, nil] The body of the `kwbegin`.
+ def body
+ return unless node_parts.any?
+
+ if rescue_node
+ rescue_node.body
+ elsif ensure_node
+ ensure_node.node_parts[0]
+ elsif node_parts.one?
+ node_parts[0]
+ else
+ self
+ end
+ end
+
+ # Returns the `rescue` node of the `kwbegin` block, if one is present.
+ #
+ # @return [Node, nil] The `rescue` node within `kwbegin`.
+ def ensure_node
+ node_parts[0] if node_parts[0]&.ensure_type?
+ end
+
+ # Returns the `rescue` node of the `kwbegin` block, if one is present.
+ #
+ # @return [Node, nil] The `rescue` node within `kwbegin`.
+ def rescue_node
+ return ensure_node&.rescue_node if ensure_node&.rescue_node
+
+ node_parts[0] if node_parts[0]&.rescue_type?
+ end
+ end
+ end
+end
* Changed:
lib/rubocop/ast.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast.rb 2024-11-27 03:31:59.157453626 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast.rb 2024-11-27 03:31:59.289454359 +0000
@@ -62,0 +63 @@
+require_relative 'ast/node/keyword_begin_node'
lib/rubocop/ast/builder.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast/builder.rb 2024-11-27 03:31:59.157453626 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/builder.rb 2024-11-27 03:31:59.289454359 +0000
@@ -65,0 +66 @@
+ kwbegin: KeywordBeginNode,
lib/rubocop/ast/node.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast/node.rb 2024-11-27 03:31:59.157453626 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/node.rb 2024-11-27 03:31:59.289454359 +0000
@@ -90,0 +91,28 @@
+ # @api private
+ GROUP_FOR_TYPE = {
+ arg: :argument,
+ optarg: :argument,
+ restarg: :argument,
+ kwarg: :argument,
+ kwoptarg: :argument,
+ kwrestarg: :argument,
+ blockarg: :argument,
+ forward_arg: :argument,
+ shardowarg: :argument,
+
+ true: :boolean,
+ false: :boolean,
+
+ int: :numeric,
+ float: :numeric,
+ rational: :numeric,
+ complex: :numeric,
+
+ irange: :range,
+ erange: :range,
+
+ send: :call,
+ csend: :call
+ }.freeze
+ private_constant :GROUP_FOR_TYPE
+
@@ -128,0 +157,10 @@
+ # Determine if the node is one of several node types in a single query
+ # Allows specific single node types, as well as "grouped" types
+ # (e.g. `:boolean` for `:true` or `:false`)
+ def type?(*types)
+ return true if types.include?(type)
+
+ group_type = GROUP_FOR_TYPE[type]
+ !group_type.nil? && types.include?(group_type)
+ end
+
@@ -315 +353 @@
- return unless const_type?
+ return unless const_type? || casgn_type?
@@ -317 +354,0 @@
- namespace, name = *self
@@ -319 +356 @@
- "#{namespace.const_name}::#{name}"
+ "#{namespace.const_name}::#{short_name}"
@@ -321 +358 @@
- name.to_s
+ short_name.to_s
@@ -467 +504 @@
- send_type? || csend_type?
+ GROUP_FOR_TYPE[type] == :call
@@ -479 +516 @@
- ARGUMENT_TYPES.include?(type)
+ GROUP_FOR_TYPE[type] == :argument
@@ -483 +520 @@
- true_type? || false_type?
+ GROUP_FOR_TYPE[type] == :boolean
@@ -487 +524 @@
- int_type? || float_type? || rational_type? || complex_type?
+ GROUP_FOR_TYPE[type] == :numeric
@@ -491 +528 @@
- irange_type? || erange_type?
+ GROUP_FOR_TYPE[type] == :range
lib/rubocop/ast/node/asgn_node.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast/node/asgn_node.rb 2024-11-27 03:31:59.157453626 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/node/asgn_node.rb 2024-11-27 03:31:59.293454381 +0000
@@ -14,0 +15 @@
+ alias lhs name
@@ -21,0 +23 @@
+ alias rhs expression
lib/rubocop/ast/node/casgn_node.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast/node/casgn_node.rb 2024-11-27 03:31:59.157453626 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/node/casgn_node.rb 2024-11-27 03:31:59.293454381 +0000
@@ -11,0 +12 @@
+ alias lhs short_name
@@ -18,0 +20 @@
+ alias rhs expression
lib/rubocop/ast/node/ensure_node.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast/node/ensure_node.rb 2024-11-27 03:31:59.161453648 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/node/ensure_node.rb 2024-11-27 03:31:59.293454381 +0000
@@ -11,0 +12 @@
+ # @deprecated Use `EnsureNode#branch`
@@ -12,0 +14,7 @@
+ branch
+ end
+
+ # Returns an the ensure branch in the exception handling statement.
+ #
+ # @return [Node, nil] the body of the ensure branch.
+ def branch
@@ -13,0 +22,7 @@
+ end
+
+ # Returns the `rescue` node of the `ensure`, if present.
+ #
+ # @return [Node, nil] The `rescue` node.
+ def rescue_node
+ node_parts[0] if node_parts[0].rescue_type?
lib/rubocop/ast/node/op_asgn_node.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast/node/op_asgn_node.rb 2024-11-27 03:31:59.281454315 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/node/op_asgn_node.rb 2024-11-27 03:31:59.297454404 +0000
@@ -12,0 +13 @@
+ alias lhs assignment_node
@@ -18 +19 @@
- assignment_node.name
+ assignment_node.call_type? ? assignment_node.method_name : assignment_node.name
@@ -33,0 +35 @@
+ alias rhs expression
lib/rubocop/ast/version.rb
--- /tmp/d20241127-10126-k8h07j/rubocop-ast-1.33.1/lib/rubocop/ast/version.rb 2024-11-27 03:31:59.289454359 +0000
+++ /tmp/d20241127-10126-k8h07j/rubocop-ast-1.36.1/lib/rubocop/ast/version.rb 2024-11-27 03:31:59.305454448 +0000
@@ -6 +6 @@
- STRING = '1.33.1'
+ STRING = '1.36.1' |
gem compare unicode-display_width 2.6.0 3.1.2 Compared versions: ["2.6.0", "3.1.2"]
DIFFERENT date:
2.6.0: 2024-09-13 00:00:00 UTC
3.1.2: 2024-11-20 00:00:00 UTC
DIFFERENT description:
2.6.0: [Unicode 16.0.0] Determines the monospace display width of a string using EastAsianWidth.txt, Unicode general category, and other data.
3.1.2: [Unicode 16.0.0] Determines the monospace display width of a string using EastAsianWidth.txt, Unicode general category, Emoji specification, and other data.
DIFFERENT required_ruby_version:
2.6.0: >= 2.4.0
3.1.2: >= 2.5.0
DIFFERENT rubygems_version:
2.6.0: 3.5.9
3.1.2: 3.5.21
DIFFERENT version:
2.6.0: 2.6.0
3.1.2: 3.1.2
DIFFERENT files:
2.6.0->3.1.2:
* Added:
lib/unicode/display_width/emoji_support.rb +52/-0
lib/unicode/display_width/reline_ext.rb +14/-0
* Changed:
CHANGELOG.md +79/-2
README.md +66/-52
lib/unicode/display_width.rb +189/-73
lib/unicode/display_width/constants.rb +1/-1
lib/unicode/display_width/string_ext.rb +3/-3
DIFFERENT extra_rdoc_files:
2.6.0->3.1.2:
* Changed:
README.md +66/-52
CHANGELOG.md +79/-2
DIFFERENT runtime dependencies:
2.6.0->3.1.2:
* Added:
unicode-emoji ["~> 4.0", ">= 4.0.4"] (runtime) |
gem compare --diff unicode-display_width 2.6.0 3.1.2 Compared versions: ["2.6.0", "3.1.2"]
DIFFERENT files:
2.6.0->3.1.2:
* Added:
lib/unicode/display_width/emoji_support.rb
--- /tmp/20241127-10636-a721n8 2024-11-27 03:32:21.577589477 +0000
+++ /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/lib/unicode/display_width/emoji_support.rb 2024-11-27 03:32:21.577589477 +0000
@@ -0,0 +1,52 @@
+# require "rbconfig"
+# RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # windows
+
+module Unicode
+ class DisplayWidth
+ module EmojiSupport
+ # Tries to find out which terminal emulator is used to
+ # set emoji: config to best suiting value
+ #
+ # Please also see section in README.md and
+ # misc/terminal-emoji-width.rb
+ #
+ # Please note: Many terminals do not set any ENV vars,
+ # maybe CSI queries can help?
+ def self.recommended
+ if ENV["CI"]
+ return :rqi
+ end
+
+ case ENV["TERM_PROGRAM"]
+ when "iTerm.app"
+ return :all
+ when "Apple_Terminal"
+ return :rgi_at
+ when "WezTerm"
+ return :all_no_vs16
+ end
+
+ case ENV["TERM"]
+ when "contour","foot"
+ # konsole: all, how to detect?
+ return :all
+ when /kitty/
+ return :vs16
+ end
+
+ if ENV["WT_SESSION"] # Windows Terminal
+ return :vs16
+ end
+
+ # As of last time checked: gnome-terminal, vscode, alacritty
+ :none
+ end
+
+ # Maybe: Implement something like https://github.com/jquast/ucs-detect
+ # which uses the terminal cursor to check for best support level
+ # at runtime
+ # def self.detect!
+ # end
+ end
+ end
+end
lib/unicode/display_width/reline_ext.rb
--- /tmp/20241127-10636-rgkewg 2024-11-27 03:32:21.581589502 +0000
+++ /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/lib/unicode/display_width/reline_ext.rb 2024-11-27 03:32:21.577589477 +0000
@@ -0,0 +1,14 @@
+# Experimental
+# Patches Reline's get_mbchar_width to use Unicode::DisplayWidth
+
+require "reline"
+require "reline/unicode"
+
+require_relative "../display_width"
+
+class Reline::Unicode
+ def self.get_mbchar_width(mbchar)
+ Unicode::DisplayWidth.of(mbchar, Reline.ambiguous_width)
+ end
+end
+
* Changed:
CHANGELOG.md
--- /tmp/d20241127-10636-ke8edu/unicode-display_width-2.6.0/CHANGELOG.md 2024-11-27 03:32:21.577589477 +0000
+++ /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/CHANGELOG.md 2024-11-27 03:32:21.577589477 +0000
@@ -2,0 +3,59 @@
+## 3.1.2
+
+- Performance improvements
+
+## 3.1.1
+
+- Performance improvements
+
+## 3.1.0
+
+**Improve Emoji support:**
+
+- Emoji modes: Differentiate between well-formed Emoji (`:possible`) and any
+ ZWJ/modifier sequence (`:all`). The latter is more common and more efficient
+ to implement.
+- Unify `:rgi_{fqe,mqe,uqe}` options to just `:rgi` to keep things simpler (corresponds to
+ the former `:rgi_uqe` option). Most terminals that want to support the RGI set
+ will probably want to catch Emoji sequences with missing VS16s.
+- Add new `:all_no_vs16` and `:rgi_at` modes to be able to support some terminals
+ that needs these quirks
+- Add alias `emoji: :auto` for `emoji: true` and `emoji: :none` for `emoji: false`
+- `:auto` mode: Only consider terminal cells when recommending Emoji support level
+ (Emoji themselves might display differently)
+- `:auto` mode: Set default Emoji mode for unknown/unsupported terminals to `:none`
+- Rename `:basic` mode to `:vs16`
+
+## 3.0.1
+
+- Add WezTerm and foot as good Emoji terminals
+
+## 3.0.0
+
+**Rework Emoji support:**
+
+- Emoji widths are now enabled by default
+- Only reduce Emoji width to 2 when RGI Emoji detected (configurable)
+- VS16 turns Emoji characters of width 1 into full-width
+- Please note that Emoji parsing has a notable impact on performance.
+ You can use the `emoji: false` option to disable Emoji adjustments
+- Tries to detect terminal's Emoji support level automatically (from ENV vars)
+
+**Index fixes and updates:**
+
+- Private-use characters are considered ambiguous (were given width 1 before)
+- Fix that a few zero-width ignorable codepoints from recent Unicode were missing
+- Consider the following separators to be zero-width:
+ - U+2028 - LINE SEPARATOR - Zl
+ - U+2029 - PARAGRAPH SEPARATOR - Zp
+
+**Other:**
+
+- Add keyword arguments to `Unicode::DisplayWidth.of`. If you are using a hash
+ with overwrite values as third parameter, be sure to put it in curly braces.
+- Using third parameter or explicit hash as fourth parameter is deprecated,
+ please migrate to the keyword arguments API
+- Gem raises `ArgumentError` for ambiguous values other than 1 or 2
+- Performance optimizations
+- Require Ruby 2.5
+
@@ -43,2 +102,20 @@
-- Release 2.0.0
-- Supports Ruby 3.0
+Add Support for Ruby 3.0
+
+### Breaking Changes
+
+Some features of this library were marked deprecated for a long time and have been removed with Version 2.0:
+
+- Aliases of display\_width (…\_size, …\_length) have been removed
+- Auto-loading of string core extension has been removed:
+
+If you are relying on the `String#display_width` string extension to be automatically loaded (old behavior), please load it explicitly now:
+
+```ruby
+require "unicode/display_width/string_ext"
+```
+
+You could also change your `Gemfile` line to achieve this:
+
+```ruby
+gem "unicode-display_width", require: "unicode/display_width/string_ext"
+```
README.md
--- /tmp/d20241127-10636-ke8edu/unicode-display_width-2.6.0/README.md 2024-11-27 03:32:21.577589477 +0000
+++ /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/README.md 2024-11-27 03:32:21.577589477 +0000
@@ -1 +1 @@
-## Unicode::DisplayWidth [![[version]](https://badge.fury.io/rb/unicode-display_width.svg)](https://badge.fury.io/rb/unicode-display_width) [<img src="https://github.com/janlelis/unicode-display_width/workflows/Test/badge.svg" />](https://github.com/janlelis/unicode-display_width/actions?query=workflow%3ATest)
+# Unicode::DisplayWidth [![[version]](https://badge.fury.io/rb/unicode-display_width.svg)](https://badge.fury.io/rb/unicode-display_width) [<img src="https://github.com/janlelis/unicode-display_width/workflows/Test/badge.svg" />](https://github.com/janlelis/unicode-display_width/actions?query=workflow%3ATest)
@@ -3 +3 @@
-Determines the monospace display width of a string in Ruby. Useful for all kinds of terminal-based applications. Implementation based on [EastAsianWidth.txt](https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt) and other data, 100% in Ruby. It does not rely on the OS vendor (like [wcwidth()](https://github.com/janlelis/wcswidth-ruby)) to provide an up-to-date method for measuring string width.
+Determines the monospace display width of a string in Ruby, which is useful for all kinds of terminal-based applications. The implementation is based on [EastAsianWidth.txt](https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt), the [Emoji specfication](https://www.unicode.org/reports/tr51/) and other data, 100% in Ruby. It does not rely on the OS vendor ([wcwidth()](https://github.com/janlelis/wcswidth-ruby)) to provide an up-to-date method for measuring string width in terminals.
@@ -7 +7 @@
-Supported Rubies: **3.3**, **3.2**, **3.1**, **3.0**
+## Gem Version 3 — Improved Emoji Support
@@ -9 +9 @@
-Old Rubies which might still work: **2.7**, **2.6**, **2.5**, **2.4**, **2.3**
+**Emoji support is now enabled by default.** See below for description and configuration possibilities.
@@ -11 +11 @@
-For even older Rubies, use version 2.3.0 of this gem: **2.3**, **2.2**, **2.1**, **2.0**, **1.9**
+**Unicode::DisplayWidth.of now takes keyword arguments:** { ambiguous:, emoji:, overwrite: }
@@ -13 +13 @@
-## Version 2.4.2 — Performance Updates
+See [CHANGELOG](/CHANGELOG.md) for details.
@@ -15,7 +15 @@
-**If you use this gem, you should really upgrade to 2.4.2 or newer. It's often 100x faster, sometimes even 1000x and more!**
-
-This is possible because the gem now detects if you use very basic (and common) characters, like ASCII characters. Furthermore, the charachter width lookup code has been optimized, so even when full-width characters are involved, the gem is much faster now.
-
-## Version 2.0 — Breaking Changes
-
-Some features of this library were marked deprecated for a long time and have been removed with Version 2.0:
+## Gem Version 2.4.2 — Performance Updates
@@ -23,10 +17 @@
-- Aliases of display_width (…\_size, …\_length) have been removed
-- Auto-loading of string core extension has been removed:
-
-If you are relying on the `String#display_width` string extension to be automatically loaded (old behavior), please load it explicitly now:
-
-```ruby
-require "unicode/display_width/string_ext"
-```
-
-You could also change your `Gemfile` line to achieve this:
+**If you use this gem, you should really upgrade to 2.4.2 or newer. It's often 100x faster, sometimes even 1000x and more!**
@@ -34,3 +19 @@
-```ruby
-gem "unicode-display_width", require: "unicode/display_width/string_ext"
-```
+This is possible because the gem now detects if you use very basic (and common) characters, like ASCII characters. Furthermore, the character width lookup code has been optimized, so even when the string involves full-width or ambiguous characters, the gem is much faster now.
@@ -48 +31,2 @@
-X | (user defined) | Overwrites any other values
+? | (user defined) | Overwrites any other values
+? | Emoji | See "How this Library Handles Emoji Width" below
@@ -54,3 +38,3 @@
-0 | General Categories: Mn, Me, Cf (non-arabic) | Excludes ARABIC format characters
-0 | `"\u{1160}".."\u{11FF}"`, `"\u{D7B0}".."\u{D7FF}"` | HANGUL JUNGSEONG
-0 | `"\u{2060}".."\u{206F}"`, `"\u{FFF0}".."\u{FFF8}"`, `"\u{E0000}".."\u{E0FFF}"` | Ignorable ranges
+0 | General Categories: Mn, Me, Zl, Zp, Cf (non-arabic)| Excludes ARABIC format characters
+0 | Derived Property: Default_Ignorable_Code_Point | Ignorable ranges
+0 | `"\u{1160}".."\u{11FF}"`, `"\u{D7B0}".."\u{D7FF}"` | HANGUL JUNGSEONG
@@ -74,2 +57,0 @@
-### Classic API
-
@@ -83 +65 @@
-#### Ambiguous Characters
+### Ambiguous Characters
@@ -92 +74 @@
-#### Custom Overwrites
+### Custom Overwrites
@@ -94 +76 @@
-You can overwrite how to handle specific code points by passing a hash (or even a proc) as third parameter:
+You can overwrite how to handle specific code points by passing a hash (or even a proc) as `overwrite:` parameter:
@@ -97 +79 @@
-Unicode::DisplayWidth.of("a\tb", 1, "\t".ord => 10)) # => tab counted as 10, so result is 12
+Unicode::DisplayWidth.of("a\tb", 1, overwrite: { "\t".ord => 10 })) # => TAB counted as 10, result is 12
@@ -101,0 +84 @@
+### Emoji
@@ -103,3 +86 @@
-#### Emoji Support
-
-Emoji width support is included, but in must be activated manually. It will adjust the string's size for modifier and zero-width joiner sequences. You also need to add the [unicode-emoji](https://github.com/janlelis/unicode-emoji) gem to your Gemfile:
+If your terminal supports it, the gem detects Emoji and Emoji sequences and adjusts the width of the measured string. This can be disabled by passing `emoji: false` as an argument:
@@ -108,2 +89,2 @@
-gem 'unicode-display_width'
-gem 'unicode-emoji'
+Unicode::DisplayWidth.of "🤾🏽♀️", emoji: :all # => 2
+Unicode::DisplayWidth.of "🤾🏽♀️", emoji: false # => 5
@@ -112 +93 @@
-Enable the emoji string width adjustments by passing `emoji: true` as fourth parameter:
+#### How this Library Handles Emoji Width
@@ -114,4 +95,37 @@
-```ruby
-Unicode::DisplayWidth.of "🤾🏽♀️" # => 5
-Unicode::DisplayWidth.of "🤾🏽♀️", 1, {}, emoji: true # => 2
-```
+There are many Emoji which get constructed by combining other Emoji in a sequence. This makes measuring the width complicated, since terminals might either display the combined Emoji or the separate parts of the Emoji individually.
+
+Another aspect where terminals disagree is whether Emoji characters which have a text presentation by default (width 1) should be turned into full-width (width 2) when combined with Variation Selector 16 (*U+FEOF*).
+
+Emoji Type | Width / Comment
+------------|----------------
+Basic/Single Emoji character without Variation Selector | No special handling
+Basic/Single Emoji character with VS15 (Text) | No special handling
+Basic/Single Emoji character with VS16 (Emoji) | 2 or East Asian Width (see table below)
+Emoji Sequence | 2 if Emoji belongs to configured Emoji set (see table below)
+
+#### Emoji Modes
+
+The `emoji:` option can be used to configure which type of Emoji should be considered to have a width of 2 and if VS16-Emoji should be widened. Other sequences are treated as non-combined Emoji, so the widths of all partial Emoji add up (e.g. width of one basic Emoji + one skin tone modifier + another basic Emoji). The following Emoji settings can be used:
+
+`emoji:` Option | VS16-Emoji Width | Emoji Sequences Width / Comment | Example Terminals
+----------------|------------------|---------------------------------|------------------
+`true` or `:auto` | - | Automatically use recommended Emoji setting for your terminal | -
+`:all` | 2 | 2 for all ZWJ/modifier/keycap sequences, even if they are not well-formed Emoji sequences | iTerm, foot
+`:all_no_vs16` | EAW (1 or 2) | 2 for all ZWJ/modifier/keycap sequences, even if they are not well-formed Emoji sequences | WezTerm
+`:possible`| 2 | 2 for all possible/well-formed Emoji sequences | ?
+`:rgi` | 2 | 2 for all [RGI Emoji](https://www.unicode.org/reports/tr51/#def_rgi_set) sequences | ?
+`:rgi_at` | EAW (1 or 2) | 1 or 2: Like `:rgi`, but Emoji sequences starting with a default-text Emoji have EAW | Apple Terminal
+`:vs16` | 2 | 2 * number of partial Emoji (sequences never considered to represent a combined Emoji) | kitty?
+`false` or `:none` | EAW (1 or 2) | No Emoji adjustments | gnome-terminal, many older terminals
+
+- *EAW:* East Asian Width
+- *RGI Emoji:* Emoji Recommended for General Interchange
+- *ZWJ:* Zero-width Joiner: Codepoint `U+200D`,used in many Emoji sequences
+
+#### Emoji Support in Terminals
+
+Unfortunately, the level of Emoji support varies a lot between terminals. While some of them are able to display (almost) all Emoji sequences correctly, others fall back to displaying sequences of basic Emoji. When `emoji: true` or `emoji: :auto` is used, the gem will attempt to set the best fitting Emoji setting for you (e.g. `:rgi_at` on "Apple_Terminal" or `false` on Gnome's terminal widget).
+
+Please note that Emoji display and number of terminal columns used might differs a lot. For example, it might be the case that a terminal does not understand which Emoji to display, but still manages to calculate the proper amount of terminal cells. The automatic Emoji support level per terminal only considers the latter (cursor position), not the actual Emoji image(s) displayed. Please [open an issue](https://github.com/janlelis/unicode-display_width/issues/new) if you notice your terminal application could use a better default value. Also see the [ucs-detect project](https://ucs-detect.readthedocs.io/results.html), which is a great resource that compares various terminal's Unicode/Emoji capabilities.
+
+**To terminal implementors reading this:** Although the practice of giving all Emoji/ZWJ sequences a width of 2 (`:all` mode described above) has some advantages, it does not lead to a particularly good developer experience. Since there is always the possibility of well-formed Emoji that are currently not supported (non-RGI / future Unicode) appearing, those sequences will take more cells. Instead of overflowing, cutting off sequences or displaying placeholder-Emoji, could it be worthwile to implement the `:rgi` option (only known Emoji get width 2) and give those unknown Emoji the space they need? This would support the idea that the meaning of an unknown Emoji sequence can still be conveyed (without messing up the terminal at the same time). Just a thought…
@@ -119 +133 @@
-#### Usage with String Extension
+### Usage with String Extension
@@ -128 +142 @@
-### Modern API: Keyword-arguments Based Config Object
+### Usage with Config Object
@@ -130 +144 @@
-Version 2.0 introduces a keyword-argument based API, which allows you to save your configuration for later-reuse. This requires an extra line of code, but has the advantage that you'll need to define your string-width options only once:
+You can use a config object that allows you to save your configuration for later-reuse. This requires an extra line of code, but has the advantage that you'll need to define your string-width options only once:
@@ -138 +152 @@
- emoji: true,
+ emoji: :all,
@@ -142 +156 @@
-display_width.of "🤾🏽♀️" # => 2
+display_width.of "🤠🤢" # => 2
@@ -146 +160 @@
-### Usage From the CLI
+### Usage from the Command-Line
data/display_width.marshal.gz
Binary files /tmp/d20241127-10636-ke8edu/unicode-display_width-2.6.0/data/display_width.marshal.gz and /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/data/display_width.marshal.gz differ
lib/unicode/display_width.rb
--- /tmp/d20241127-10636-ke8edu/unicode-display_width-2.6.0/lib/unicode/display_width.rb 2024-11-27 03:32:21.577589477 +0000
+++ /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/lib/unicode/display_width.rb 2024-11-27 03:32:21.577589477 +0000
@@ -2,0 +3,2 @@
+require "unicode/emoji"
+
@@ -4,0 +7 @@
+require_relative "display_width/emoji_support"
@@ -7,0 +11 @@
+ DEFAULT_AMBIGUOUS = 1
@@ -9,2 +13,39 @@
- ASCII_NON_ZERO_REGEX = /[\0\x05\a\b\n\v\f\r\x0E\x0F]/
- FIRST_4096 = decompress_index(INDEX[0][0], 1)
+ ASCII_NON_ZERO_REGEX = /[\0\x05\a\b\n-\x0F]/
+ ASCII_NON_ZERO_STRING = "\0\x05\a\b\n-\x0F"
+ ASCII_BACKSPACE = "\b"
+ AMBIGUOUS_MAP = {
+ 1 => :WIDTH_ONE,
+ 2 => :WIDTH_TWO,
+ }
+ FIRST_AMBIGUOUS = {
+ WIDTH_ONE: 768,
+ WIDTH_TWO: 161,
+ }
+ NOT_COMMON_NARROW_REGEX = {
+ WIDTH_ONE: /[^\u{10}-\u{2FF}]/m,
+ WIDTH_TWO: /[^\u{10}-\u{A1}]/m,
+ }
+ FIRST_4096 = {
+ WIDTH_ONE: decompress_index(INDEX[:WIDTH_ONE][0][0], 1),
+ WIDTH_TWO: decompress_index(INDEX[:WIDTH_TWO][0][0], 1),
+ }
+ EMOJI_SEQUENCES_REGEX_MAPPING = {
+ rgi: :REGEX_INCLUDE_MQE_UQE,
+ rgi_at: :REGEX_INCLUDE_MQE_UQE,
+ possible: :REGEX_WELL_FORMED,
+ }
+ REGEX_EMOJI_VS16 = Regexp.union(
+ Regexp.compile(
+ Unicode::Emoji::REGEX_TEXT_PRESENTATION.source +
+ "(?<![#*0-9])" +
+ "\u{FE0F}"
+ ),
+ Unicode::Emoji::REGEX_EMOJI_KEYCAP
+ )
+ REGEX_EMOJI_ALL_SEQUENCES = Regexp.union(/.[\u{1F3FB}-\u{1F3FF}\u{FE0F}]?(\u{200D}.[\u{1F3FB}-\u{1F3FF}\u{FE0F}]?)+/, Unicode::Emoji::REGEX_EMOJI_KEYCAP)
+ REGEX_EMOJI_ALL_SEQUENCES_AND_VS16 = Regexp.union(REGEX_EMOJI_ALL_SEQUENCES, REGEX_EMOJI_VS16)
+
+ # Returns monospace display width of string
+ def self.of(string, ambiguous = nil, overwrite = nil, old_options = {}, **options)
+ string = string.encode(Encoding::UTF_8) unless string.encoding == Encoding::UTF_8
+ options = normalize_options(string, ambiguous, overwrite, old_options, **options)
@@ -12,12 +53,27 @@
- def self.of(string, ambiguous = 1, overwrite = {}, options = {})
- if overwrite.empty?
- # Optimization for ASCII-only strings without certain control symbols
- if string.ascii_only?
- if string.match?(ASCII_NON_ZERO_REGEX)
- res = string.gsub(ASCII_NON_ZERO_REGEX, "").size - string.count("\b")
- res < 0 ? 0 : res
- else
- string.size
- end
- else
- width_no_overwrite(string, ambiguous, options)
+ width = 0
+
+ unless options[:overwrite].empty?
+ width, string = width_custom(string, options[:overwrite])
+ end
+
+ if string.ascii_only?
+ return width + width_ascii(string)
+ end
+
+ ambiguous_index_name = AMBIGUOUS_MAP[options[:ambiguous]]
+
+ unless string.match?(NOT_COMMON_NARROW_REGEX[ambiguous_index_name])
+ return width + string.size
+ end
+
+ # Retrieve Emoji width
+ if options[:emoji] != :none
+ e_width, string = emoji_width(
+ string,
+ options[:emoji],
+ options[:ambiguous],
+ )
+ width += e_width
+
+ unless string.match?(NOT_COMMON_NARROW_REGEX[ambiguous_index_name])
+ return width + string.size
@@ -25,2 +80,0 @@
- else
- width_all_features(string, ambiguous, overwrite, options)
@@ -28 +81,0 @@
- end
@@ -30,5 +83,7 @@
- def self.width_no_overwrite(string, ambiguous, options = {})
- # Sum of all chars widths
- res = string.codepoints.sum{ |codepoint|
- if codepoint > 15 && codepoint < 161 # very common
- next 1
+ index_full = INDEX[ambiguous_index_name]
+ index_low = FIRST_4096[ambiguous_index_name]
+ first_ambiguous = FIRST_AMBIGUOUS[ambiguous_index_name]
+
+ string.each_codepoint{ |codepoint|
+ if codepoint > 15 && codepoint < first_ambiguous
+ width += 1
@@ -36 +91 @@
- width = FIRST_4096[codepoint]
+ width += index_low[codepoint] || 1
@@ -38,5 +93,4 @@
- width = INDEX
- depth = INITIAL_DEPTH
- while (width = width[codepoint / depth]).instance_of? Array
- codepoint %= depth
- depth /= 16
+ d = INITIAL_DEPTH
+ w = index_full[codepoint / d]
+ while w.instance_of? Array
+ w = w[(codepoint %= d) / (d /= 16)]
@@ -44 +97,0 @@
- end
@@ -46 +99,2 @@
- width == :A ? ambiguous : (width || 1)
+ width += w || 1
+ end
@@ -49,3 +102,0 @@
- # Substract emoji error
- res -= emoji_extra_width_of(string, ambiguous) if options[:emoji]
-
@@ -53 +104 @@
- res < 0 ? 0 : res
+ width < 0 ? 0 : width
@@ -56,5 +107,3 @@
- # Same as .width_no_overwrite - but with applying overwrites for each char
- def self.width_all_features(string, ambiguous, overwrite, options)
- # Sum of all chars widths
- res = string.codepoints.sum{ |codepoint|
- next overwrite[codepoint] if overwrite[codepoint]
+ # Returns width of custom overwrites and remaining string
+ def self.width_custom(string, overwrite)
+ width = 0
@@ -62,4 +111,4 @@
- if codepoint > 15 && codepoint < 161 # very common
- next 1
- elsif codepoint < 0x1001
- width = FIRST_4096[codepoint]
+ string = string.each_codepoint.select{ |codepoint|
+ if overwrite[codepoint]
+ width += overwrite[codepoint]
+ nil
@@ -67,6 +116 @@
- width = INDEX
- depth = INITIAL_DEPTH
- while (width = width[codepoint / depth]).instance_of? Array
- codepoint %= depth
- depth /= 16
- end
+ codepoint
@@ -73,0 +118 @@
+ }.pack("U*")
@@ -75,2 +120,2 @@
- width == :A ? ambiguous : (width || 1)
- }
+ [width, string]
+ end
@@ -78,2 +123,6 @@
- # Substract emoji error
- res -= emoji_extra_width_of(string, ambiguous, overwrite) if options[:emoji]
+ # Returns width for ASCII-only strings. Will consider zero-width control symbols.
+ def self.width_ascii(string)
+ if string.match?(ASCII_NON_ZERO_REGEX)
+ res = string.delete(ASCII_NON_ZERO_STRING).bytesize - string.count(ASCII_BACKSPACE)
+ return res < 0 ? 0 : res
+ end
@@ -81,2 +130 @@
- # Return result + prevent negative lengths
- res < 0 ? 0 : res
+ string.bytesize
@@ -84,0 +133,23 @@
+ # Returns width of all considered Emoji and remaining string
+ def self.emoji_width(string, mode = :all, ambiguous = DEFAULT_AMBIGUOUS)
+ res = 0
+
+ if emoji_set_regex = EMOJI_SEQUENCES_REGEX_MAPPING[mode]
+ emoji_width_via_possible(
+ string,
+ Unicode::Emoji.const_get(emoji_set_regex),
+ mode == :rgi_at,
+ ambiguous,
+ )
+
+ elsif mode == :all_no_vs16
+ no_emoji_string = string.gsub(REGEX_EMOJI_ALL_SEQUENCES){ res += 2; "" }
+ [res, no_emoji_string]
+
+ elsif mode == :vs16
+ no_emoji_string = string.gsub(REGEX_EMOJI_VS16){ res += 2; "" }
+ [res, no_emoji_string]
+
+ elsif mode == :all
+ no_emoji_string = string.gsub(REGEX_EMOJI_ALL_SEQUENCES_AND_VS16){ res += 2; "" }
+ [res, no_emoji_string]
@@ -86,2 +157,2 @@
- def self.emoji_extra_width_of(string, ambiguous = 1, overwrite = {}, _ = {})
- require "unicode/emoji"
+ else
+ [0, string]
@@ -89,3 +160,2 @@
- extra_width = 0
- modifier_regex = /[#{ Unicode::Emoji::EMOJI_MODIFIERS.pack("U*") }]/
- zwj_regex = /(?<=#{ [Unicode::Emoji::ZWJ].pack("U") })./
+ end
+ end
@@ -93,2 +163,14 @@
- string.scan(Unicode::Emoji::REGEX){ |emoji|
- extra_width += 2 * emoji.scan(modifier_regex).size
+ # Match possible Emoji first, then refine
+ def self.emoji_width_via_possible(string, emoji_set_regex, strict_eaw = false, ambiguous = DEFAULT_AMBIGUOUS)
+ res = 0
+
+ # For each string possibly an emoji
+ no_emoji_string = string.gsub(REGEX_EMOJI_ALL_SEQUENCES_AND_VS16){ |emoji_candidate|
+ # Check if we have a combined Emoji with width 2 (or EAW an Apple Terminal)
+ if emoji_candidate == emoji_candidate[emoji_set_regex]
+ if strict_eaw
+ res += self.of(emoji_candidate[0], ambiguous, emoji: false)
+ else
+ res += 2
+ end
+ ""
@@ -96,3 +178,9 @@
- emoji.scan(zwj_regex){ |zwj_succ|
- extra_width += self.of(zwj_succ, ambiguous, overwrite)
- }
+ # We are dealing with a default text presentation emoji or a well-formed sequence not matching the above Emoji set
+ else
+ if !strict_eaw
+ # Ensure all explicit VS16 sequences have width 2
+ emoji_candidate.gsub!(REGEX_EMOJI_VS16){ res += 2; "" }
+ end
+
+ emoji_candidate
+ end
@@ -101 +189,29 @@
- extra_width
+ [res, no_emoji_string]
+ end
+
+ def self.normalize_options(string, ambiguous = nil, overwrite = nil, old_options = {}, **options)
+ unless old_options.empty?
+ warn "Unicode::DisplayWidth: Please migrate to keyword arguments - #{old_options.inspect}"
+ options.merge! old_options
+ end
+
+ options[:ambiguous] = ambiguous if ambiguous
+ options[:ambiguous] ||= DEFAULT_AMBIGUOUS
+
+ if options[:ambiguous] != 1 && options[:ambiguous] != 2
+ raise ArgumentError, "Unicode::DisplayWidth: Ambiguous width must be 1 or 2"
+ end
+
+ if overwrite && !overwrite.empty?
+ warn "Unicode::DisplayWidth: Please migrate to keyword arguments - overwrite: #{overwrite.inspect}"
+ options[:overwrite] = overwrite
+ end
+ options[:overwrite] ||= {}
+
+ if [nil, true, :auto].include?(options[:emoji])
+ options[:emoji] = EmojiSupport.recommended
+ elsif options[:emoji] == false
+ options[:emoji] = :none
+ end
+
+ options
@@ -104 +220 @@
- def initialize(ambiguous: 1, overwrite: {}, emoji: false)
+ def initialize(ambiguous: DEFAULT_AMBIGUOUS, overwrite: {}, emoji: true)
@@ -111,5 +227,5 @@
- [
- kwargs[:ambiguous] || @ambiguous,
- kwargs[:overwrite] || @overwrite,
- { emoji: kwargs[:emoji] || @emoji },
- ]
+ {
+ ambiguous: kwargs[:ambiguous] || @ambiguous,
+ overwrite: kwargs[:overwrite] || @overwrite,
+ emoji: kwargs[:emoji] || @emoji,
+ }
@@ -119 +235 @@
- self.class.of(string, *get_config(**kwargs))
+ self.class.of(string, **get_config(**kwargs))
lib/unicode/display_width/constants.rb
--- /tmp/d20241127-10636-ke8edu/unicode-display_width-2.6.0/lib/unicode/display_width/constants.rb 2024-11-27 03:32:21.577589477 +0000
+++ /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/lib/unicode/display_width/constants.rb 2024-11-27 03:32:21.577589477 +0000
@@ -5 +5 @@
- VERSION = "2.6.0"
+ VERSION = "3.1.2"
lib/unicode/display_width/string_ext.rb
--- /tmp/d20241127-10636-ke8edu/unicode-display_width-2.6.0/lib/unicode/display_width/string_ext.rb 2024-11-27 03:32:21.577589477 +0000
+++ /tmp/d20241127-10636-ke8edu/unicode-display_width-3.1.2/lib/unicode/display_width/string_ext.rb 2024-11-27 03:32:21.577589477 +0000
@@ -3 +3 @@
-require_relative "../display_width" unless defined? Unicode::DisplayWidth
+require_relative "../display_width"
@@ -6,2 +6,2 @@
- def display_width(ambiguous = 1, overwrite = {}, options = {})
- Unicode::DisplayWidth.of(self, ambiguous, overwrite, options)
+ def display_width(ambiguous = nil, overwrite = nil, old_options = {}, **options)
+ Unicode::DisplayWidth.of(self, ambiguous, overwrite, old_options = {}, **options) |
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.68.0 to 1.69.0. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v1.68.0...v1.69.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
dependabot
bot
force-pushed
the
dependabot/bundler/rubocop-1.69.0
branch
from
December 2, 2024 14:52
15db562
to
6303161
Compare
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.68.0 to 1.69.0.
Release notes
Sourced from rubocop's releases.
... (truncated)
Changelog
Sourced from rubocop's changelog.
Commits
9a49a33
Cut 1.6996833cd
Update Changelog32c8dd5
Merge pull request #13498 from dvandersluis/useless-include-util2904985
Remove unnecessaryinclude Util
77f3e6f
Create Style/FileTouch cop8ac8947
Fix infinite loop error forStyle/IfWithSemicolon
beb22bc
UpdateStyle/SingleArgumentDig
to not register offenses on chaineddig
ca...c8cdb3d
[Fix #13486] Add newStyle/DigChain
copefc3fd8
[Fix #13490] Add newStyle/FileNull
cop8717f11
Remove unnecessaryinclude IgnoredNode
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)