diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 49cb449286..09ec123d84 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -129,7 +129,7 @@ GEM rubocop-rspec (2.2.0) rubocop (~> 1.0) rubocop-ast (>= 1.1.0) - rubocop-sorbet (0.5.1) + rubocop-sorbet (0.6.0) rubocop ruby-macho (2.5.0) ruby-progressbar (1.11.0) diff --git a/Library/Homebrew/sorbet/rbi/gems/rubocop-sorbet@0.5.1.rbi b/Library/Homebrew/sorbet/rbi/gems/rubocop-sorbet@0.6.0.rbi similarity index 81% rename from Library/Homebrew/sorbet/rbi/gems/rubocop-sorbet@0.5.1.rbi rename to Library/Homebrew/sorbet/rbi/gems/rubocop-sorbet@0.6.0.rbi index 6fffaa4442..7494411ca6 100644 --- a/Library/Homebrew/sorbet/rbi/gems/rubocop-sorbet@0.5.1.rbi +++ b/Library/Homebrew/sorbet/rbi/gems/rubocop-sorbet@0.6.0.rbi @@ -72,17 +72,20 @@ RuboCop::Cop::Sorbet::EnforceSigilOrder::MAGIC_REGEX = T.let(T.unsafe(nil), Rege RuboCop::Cop::Sorbet::EnforceSigilOrder::PREFERRED_ORDER = T.let(T.unsafe(nil), Hash) class RuboCop::Cop::Sorbet::EnforceSignatures < ::RuboCop::Cop::Sorbet::SignatureCop + def initialize(config = T.unsafe(nil), options = T.unsafe(nil)); end + def accessor?(param0 = T.unsafe(nil)); end def autocorrect(node); end + def on_block(node); end def on_def(node); end def on_defs(node); end def on_send(node); end + def scope(node); end private def check_node(node); end def param_type_placeholder; end - def previous_node(node); end def return_type_placeholder; end end @@ -90,9 +93,9 @@ class RuboCop::Cop::Sorbet::EnforceSignatures::SigSuggestion def initialize(indent, param_placeholder, return_placeholder); end def params; end - def params=(_); end + def params=(_arg0); end def returns; end - def returns=(_); end + def returns=(_arg0); end def to_autocorrect; end private @@ -105,13 +108,26 @@ class RuboCop::Cop::Sorbet::FalseSigil < ::RuboCop::Cop::Sorbet::HasSigil def minimum_strictness; end end +class RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims < ::RuboCop::Cop::Cop + include(::RuboCop::Cop::RangeHelp) + + def autocorrect(node); end + def extend_t_helpers?(param0 = T.unsafe(nil)); end + def extend_t_sig?(param0 = T.unsafe(nil)); end + def on_send(node); end +end + +RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims::MSG = T.let(T.unsafe(nil), String) + +RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array) + class RuboCop::Cop::Sorbet::ForbidIncludeConstLiteral < ::RuboCop::Cop::Cop - def initialize(*_); end + def initialize(*_arg0); end def not_lit_const_include?(param0 = T.unsafe(nil)); end def on_send(node); end def used_names; end - def used_names=(_); end + def used_names=(_arg0); end end RuboCop::Cop::Sorbet::ForbidIncludeConstLiteral::MSG = T.let(T.unsafe(nil), String) @@ -150,6 +166,22 @@ class RuboCop::Cop::Sorbet::KeywordArgumentOrdering < ::RuboCop::Cop::Sorbet::Si def check_order_for_kwoptargs(parameters); end end +class RuboCop::Cop::Sorbet::OneAncestorPerLine < ::RuboCop::Cop::Cop + def abstract?(param0); end + def autocorrect(node); end + def more_than_one_ancestor(param0 = T.unsafe(nil)); end + def on_class(node); end + def on_module(node); end + def requires_ancestors(param0); end + + private + + def new_ra_line(indent_count); end + def process_node(node); end +end + +RuboCop::Cop::Sorbet::OneAncestorPerLine::MSG = T.let(T.unsafe(nil), String) + class RuboCop::Cop::Sorbet::ParametersOrderingInSignature < ::RuboCop::Cop::Sorbet::SignatureCop def on_signature(node); end def signature_params(param0); end @@ -169,7 +201,7 @@ class RuboCop::Cop::Sorbet::SignatureBuildOrder < ::RuboCop::Cop::Sorbet::Signat def call_chain(sig_child_node); end def can_autocorrect?; end - def node_with_index_sends(node); end + def node_reparsed_with_modern_features(node); end end RuboCop::Cop::Sorbet::SignatureBuildOrder::ORDER = T.let(T.unsafe(nil), Hash) @@ -180,6 +212,19 @@ class RuboCop::Cop::Sorbet::SignatureCop < ::RuboCop::Cop::Cop def signature?(param0 = T.unsafe(nil)); end end +class RuboCop::Cop::Sorbet::SingleLineRbiClassModuleDefinitions < ::RuboCop::Cop::Cop + def autocorrect(node); end + def on_class(node); end + def on_module(node); end + + protected + + def convert_newlines(source); end + def process_node(node); end +end + +RuboCop::Cop::Sorbet::SingleLineRbiClassModuleDefinitions::MSG = T.let(T.unsafe(nil), String) + class RuboCop::Cop::Sorbet::StrictSigil < ::RuboCop::Cop::Sorbet::HasSigil def minimum_strictness; end end diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index 8ff0c4c282..4c17971b6a 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -85,7 +85,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.11.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.10.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.2.0/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-stub-0.2.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thor-1.1.0/lib" diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/config/default.yml b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/config/default.yml similarity index 87% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/config/default.yml rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/config/default.yml index 4e1602c037..8da8125ac8 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/config/default.yml +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/config/default.yml @@ -53,6 +53,13 @@ Sorbet/FalseSigil: - db/**/*.rb - script/**/* +Sorbet/ForbidExtendTSigHelpersInShims: + Description: 'Forbid the use of `extend T::Sig` and `extend T::Helpers` in RBI shims' + Enabled: true + VersionAdded: '0.6.0' + Include: + - "**/*.rbi" + Sorbet/ForbidIncludeConstLiteral: Description: 'Forbids include of non-literal constants.' Enabled: false @@ -92,6 +99,11 @@ Sorbet/KeywordArgumentOrdering: Enabled: true VersionAdded: 0.2.0 +Sorbet/OnedAncestorPerLine: + Description: 'Enforces one ancestor per call to requires_ancestor' + Enabled: false + VersionAdded: '0.6.0' + Sorbet/ParametersOrderingInSignature: Description: 'Enforces same parameter order between a method and its signature.' Enabled: true @@ -107,6 +119,13 @@ Sorbet/SignatureBuildOrder: Enabled: true VersionAdded: 0.3.0 +Sorbet/SingleLineRbiClassModuleDefinitions: + Description: 'Empty class and module definitions in RBI must be on a single line.' + Enabled: false + VersionAdded: '0.6.0' + Include: + - "**/*.rbi" + Sorbet/StrictSigil: Description: 'All files must be at least at strictness `strict`.' Enabled: false diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop-sorbet.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop-sorbet.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop-sorbet.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop-sorbet.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/constants_from_strings.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/constants_from_strings.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/constants_from_strings.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/constants_from_strings.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_extend_t_sig_helpers_in_shims.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_extend_t_sig_helpers_in_shims.rb new file mode 100644 index 0000000000..2a281fc868 --- /dev/null +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_extend_t_sig_helpers_in_shims.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Sorbet + # This cop ensures RBI shims do not include a call to extend T::Sig + # or to extend T::Helpers + # + # @example + # + # # bad + # module SomeModule + # extend T::Sig + # extend T::Helpers + # + # sig { returns(String) } + # def foo; end + # end + # + # # good + # module SomeModule + # sig { returns(String) } + # def foo; end + # end + class ForbidExtendTSigHelpersInShims < RuboCop::Cop::Cop + include RangeHelp + + MSG = 'Extending T::Sig or T::Helpers in a shim is unnecessary' + RESTRICT_ON_SEND = [:extend] + + def_node_matcher :extend_t_sig?, <<~PATTERN + (send nil? :extend (const (const nil? :T) :Sig)) + PATTERN + + def_node_matcher :extend_t_helpers?, <<~PATTERN + (send nil? :extend (const (const nil? :T) :Helpers)) + PATTERN + + def autocorrect(node) + -> (corrector) do + corrector.remove( + range_by_whole_lines(node.source_range, include_final_newline: true) + ) + end + end + + def on_send(node) + add_offense(node) if extend_t_helpers?(node) || extend_t_sig?(node) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/forbid_include_const_literal.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_include_const_literal.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/forbid_include_const_literal.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_include_const_literal.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/one_ancestor_per_line.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/one_ancestor_per_line.rb new file mode 100644 index 0000000000..cb4d1abc49 --- /dev/null +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/one_ancestor_per_line.rb @@ -0,0 +1,75 @@ +# encoding: utf-8 +# frozen_string_literal: true + +require 'rubocop' + +module RuboCop + module Cop + module Sorbet + # This cop ensures one ancestor per requires_ancestor line + # rather than chaining them as a comma-separated list. + # + # @example + # + # # bad + # module SomeModule + # requires_ancestor Kernel, Minitest::Assertions + # end + # + # # good + # module SomeModule + # requires_ancestor Kernel + # requires_ancestor Minitest::Assertions + # end + class OneAncestorPerLine < RuboCop::Cop::Cop + MSG = 'Cannot require more than one ancestor per line' + + def_node_search :requires_ancestors, <<~PATTERN + (send nil? :requires_ancestor ...) + PATTERN + + def_node_matcher :more_than_one_ancestor, <<~PATTERN + (send nil? :requires_ancestor const const+) + PATTERN + + def_node_search :abstract?, <<~PATTERN + (send nil? :abstract!) + PATTERN + + def on_module(node) + return unless node.body + return unless requires_ancestors(node) + process_node(node) + end + + def on_class(node) + return unless abstract?(node) + return unless requires_ancestors(node) + process_node(node) + end + + def autocorrect(node) + -> (corrector) do + ra_call = node.parent + split_ra_calls = ra_call.source.gsub(/,\s+/, new_ra_line(ra_call.loc.column)) + corrector.replace(ra_call, split_ra_calls) + end + end + + private + + def process_node(node) + requires_ancestors(node).each do |ra| + add_offense(ra.child_nodes[1]) if more_than_one_ancestor(ra) + end + end + + def new_ra_line(indent_count) + indents = " " * indent_count + indented_ra_call = "#{indents}requires_ancestor " + "\n#{indented_ra_call}" + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/false_sigil.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/false_sigil.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/false_sigil.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/false_sigil.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/has_sigil.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/has_sigil.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/has_sigil.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/has_sigil.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/ignore_sigil.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/ignore_sigil.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/ignore_sigil.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/ignore_sigil.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/strict_sigil.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/strict_sigil.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/strict_sigil.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/strict_sigil.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/strong_sigil.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/strong_sigil.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/strong_sigil.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/strong_sigil.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/true_sigil.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/true_sigil.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/true_sigil.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/true_sigil.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/valid_sigil.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/valid_sigil.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/sigils/valid_sigil.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/sigils/valid_sigil.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/checked_true_in_signature.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb similarity index 85% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb index 92e1f73642..16c915df2c 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb @@ -27,6 +27,11 @@ module RuboCop # * `ParameterTypePlaceholder`: placeholders used for parameter types (default: 'T.untyped') # * `ReturnTypePlaceholder`: placeholders used for return types (default: 'T.untyped') class EnforceSignatures < SignatureCop + def initialize(config = nil, options = nil) + super(config, options) + @last_sig_for_scope = {} + end + def_node_matcher(:accessor?, <<-PATTERN) (send nil? {:attr_reader :attr_writer :attr_accessor} ...) PATTERN @@ -40,8 +45,11 @@ module RuboCop end def on_send(node) - return unless accessor?(node) - check_node(node) + check_node(node) if accessor?(node) + end + + def on_block(node) + @last_sig_for_scope[scope(node)] = node if signature?(node) end def autocorrect(node) @@ -63,22 +71,23 @@ module RuboCop end end + def scope(node) + return nil unless node.parent + return node.parent if [:begin, :block, :class, :module].include?(node.parent.type) + scope(node.parent) + end + private def check_node(node) - prev = previous_node(node) - unless signature?(prev) + scope = self.scope(node) + unless @last_sig_for_scope[scope] add_offense( node, message: "Each method is required to have a signature." ) end - end - - def previous_node(node) - parent = node.parent - return nil unless parent - parent.children[node.sibling_index - 1] + @last_sig_for_scope[scope] = nil end def param_type_placeholder diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb similarity index 68% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb index 245cf8fbf3..dafc757e3d 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb @@ -55,7 +55,7 @@ module RuboCop return nil unless can_autocorrect? lambda do |corrector| - tree = call_chain(node_with_index_sends(node)) + tree = call_chain(node_reparsed_with_modern_features(node)) .sort_by { |call| ORDER[call.method_name] } .reduce(nil) do |receiver, caller| caller.updated(nil, [receiver] + caller.children.drop(1)) @@ -68,16 +68,25 @@ module RuboCop end end + # Create a subclass of AST Builder that has modern features turned on + class ModernBuilder < RuboCop::AST::Builder + modernize + end + private_constant :ModernBuilder + private - def node_with_index_sends(node) - # This is really dirty hack to reparse the current node with index send - # emitting enabled, which is necessary to unparse them back as index accessors. - emit_index_value = RuboCop::AST::Builder.emit_index - RuboCop::AST::Builder.emit_index = true - RuboCop::AST::ProcessedSource.new(node.source, target_ruby_version, processed_source.path).ast - ensure - RuboCop::AST::Builder.emit_index = emit_index_value + # This method exists to reparse the current node with modern features enabled. + # Modern features include "index send" emitting, which is necessary to unparse + # "index sends" (i.e. `[]` calls) back to index accessors (i.e. as `foo[bar]``). + # Otherwise, we would get the unparsed node as `foo.[](bar)`. + def node_reparsed_with_modern_features(node) + # Create a new parser with a modern builder class instance + parser = Parser::CurrentRuby.new(ModernBuilder.new) + # Create a new source buffer with the node source + buffer = Parser::Source::Buffer.new(processed_source.path, source: node.source) + # Re-parse the buffer + parser.parse(buffer) end def can_autocorrect? diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/signature_cop.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/signature_cop.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet/signatures/signature_cop.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/signatures/signature_cop.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/single_line_rbi_class_module_definitions.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/single_line_rbi_class_module_definitions.rb new file mode 100644 index 0000000000..712e33844b --- /dev/null +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet/single_line_rbi_class_module_definitions.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Sorbet + # This cop ensures empty class/module definitions in RBI files are + # done on a single line rather than being split across multiple lines. + # + # @example + # + # # bad + # module SomeModule + # end + # + # # good + # module SomeModule; end + class SingleLineRbiClassModuleDefinitions < RuboCop::Cop::Cop + MSG = 'Empty class/module definitions in RBI files should be on a single line.' + + def on_module(node) + process_node(node) + end + + def on_class(node) + process_node(node) + end + + def autocorrect(node) + -> (corrector) { corrector.replace(node, convert_newlines(node.source)) } + end + + protected + + def convert_newlines(source) + source.sub(/[\r\n]+\s*[\r\n]*/, "; ") + end + + def process_node(node) + return if node.body + return if node.single_line? + add_offense(node) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet_cops.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet_cops.rb similarity index 85% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet_cops.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet_cops.rb index b61037489f..ae9006a095 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/cop/sorbet_cops.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/cop/sorbet_cops.rb @@ -1,9 +1,12 @@ # frozen_string_literal: true require_relative 'sorbet/binding_constants_without_type_alias' require_relative 'sorbet/constants_from_strings' +require_relative 'sorbet/forbid_extend_t_sig_helpers_in_shims' require_relative 'sorbet/forbid_superclass_const_literal' require_relative 'sorbet/forbid_include_const_literal' require_relative 'sorbet/forbid_untyped_struct_props' +require_relative 'sorbet/single_line_rbi_class_module_definitions' +require_relative 'sorbet/one_ancestor_per_line' require_relative 'sorbet/signatures/allow_incompatible_override' require_relative 'sorbet/signatures/checked_true_in_signature' diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/sorbet.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/sorbet.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/sorbet.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/sorbet.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/sorbet/inject.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/sorbet/inject.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/sorbet/inject.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/sorbet/inject.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/sorbet/version.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/sorbet/version.rb similarity index 76% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/sorbet/version.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/sorbet/version.rb index ea49b569f3..cb4e7f9e0e 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib/rubocop/sorbet/version.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.0/lib/rubocop/sorbet/version.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true module RuboCop module Sorbet - VERSION = "0.5.1" + VERSION = "0.6.0" end end