Merge pull request #14529 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-sorbet-0.7.0
build(deps): bump rubocop-sorbet from 0.6.11 to 0.7.0 in /Library/Homebrew
This commit is contained in:
commit
fe9af82808
@ -154,7 +154,7 @@ GEM
|
||||
rubocop-rspec (2.18.1)
|
||||
rubocop (~> 1.33)
|
||||
rubocop-capybara (~> 2.17)
|
||||
rubocop-sorbet (0.6.11)
|
||||
rubocop-sorbet (0.7.0)
|
||||
rubocop (>= 0.90.0)
|
||||
ruby-macho (3.0.0)
|
||||
ruby-progressbar (1.11.0)
|
||||
|
||||
@ -830,8 +830,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
||||
end
|
||||
|
||||
# @see VCSDownloadStrategy#last_commit
|
||||
sig { returns(String) }
|
||||
# @api public
|
||||
sig { returns(String) }
|
||||
def last_commit
|
||||
out, = silent_command("git", args: ["--git-dir", git_dir, "rev-parse", "--short=7", "HEAD"])
|
||||
out.chomp
|
||||
|
||||
@ -484,7 +484,6 @@ module ObserverPathnameExtension
|
||||
end
|
||||
|
||||
sig { returns([Integer, Integer]) }
|
||||
|
||||
def counts
|
||||
[n, d]
|
||||
end
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
module RuboCop; end
|
||||
module RuboCop::Cop; end
|
||||
RuboCop::Cop::IgnoredMethods = RuboCop::Cop::AllowedMethods
|
||||
RuboCop::Cop::IgnoredPattern = RuboCop::Cop::AllowedPattern
|
||||
module RuboCop::Cop::Sorbet; end
|
||||
|
||||
@ -55,6 +56,17 @@ class RuboCop::Cop::Sorbet::ConstantsFromStrings < ::RuboCop::Cop::Cop
|
||||
def on_send(node); end
|
||||
end
|
||||
|
||||
class RuboCop::Cop::Sorbet::EmptyLineAfterSig < ::RuboCop::Cop::Sorbet::SignatureCop
|
||||
include ::RuboCop::Cop::RangeHelp
|
||||
|
||||
def autocorrect(node); end
|
||||
def on_signature(node); end
|
||||
|
||||
private
|
||||
|
||||
def next_method(node); end
|
||||
end
|
||||
|
||||
class RuboCop::Cop::Sorbet::EnforceSigilOrder < ::RuboCop::Cop::Sorbet::ValidSigil
|
||||
include ::RuboCop::Cop::RangeHelp
|
||||
|
||||
@ -175,6 +187,7 @@ end
|
||||
class RuboCop::Cop::Sorbet::ForbidUntypedStructProps < ::RuboCop::Cop::Cop
|
||||
def on_class(node); end
|
||||
def subclass_of_t_struct?(param0 = T.unsafe(nil)); end
|
||||
def t_immutable_struct(param0 = T.unsafe(nil)); end
|
||||
def t_nilable_untyped(param0 = T.unsafe(nil)); end
|
||||
def t_struct(param0 = T.unsafe(nil)); end
|
||||
def t_untyped(param0 = T.unsafe(nil)); end
|
||||
@ -223,6 +236,15 @@ end
|
||||
|
||||
RuboCop::Cop::Sorbet::OneAncestorPerLine::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::Sorbet::RedundantExtendTSig < ::RuboCop::Cop::Cop
|
||||
def autocorrect(node); end
|
||||
def extend_t_sig?(param0 = T.unsafe(nil)); end
|
||||
def on_send(node); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Sorbet::RedundantExtendTSig::MSG = T.let(T.unsafe(nil), String)
|
||||
RuboCop::Cop::Sorbet::RedundantExtendTSig::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::Sorbet::SignatureBuildOrder < ::RuboCop::Cop::Sorbet::SignatureCop
|
||||
def autocorrect(node); end
|
||||
def on_signature(node); end
|
||||
@ -239,7 +261,6 @@ class RuboCop::Cop::Sorbet::SignatureBuildOrder::ModernBuilder < ::RuboCop::AST:
|
||||
RuboCop::Cop::Sorbet::SignatureBuildOrder::ORDER = T.let(T.unsafe(nil), Hash)
|
||||
|
||||
class RuboCop::Cop::Sorbet::SignatureCop < ::RuboCop::Cop::Cop
|
||||
def allowed_recv(recv); end
|
||||
def on_block(node); end
|
||||
def on_signature(_); end
|
||||
def signature?(param0 = T.unsafe(nil)); end
|
||||
@ -108,7 +108,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.15.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.17.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.18.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.6.11/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-html-0.12.3/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov_json_formatter-0.1.4/lib")
|
||||
|
||||
@ -25,6 +25,11 @@ Sorbet/CheckedTrueInSignature:
|
||||
Enabled: true
|
||||
VersionAdded: 0.2.0
|
||||
|
||||
Sorbet/EmptyLineAfterSig:
|
||||
Description: 'Ensures that there are no blank lines after signatures'
|
||||
Enabled: true
|
||||
VersionAdded: 0.7.0
|
||||
|
||||
Sorbet/ConstantsFromStrings:
|
||||
Description: >-
|
||||
Forbids constant access through meta-programming.
|
||||
@ -42,7 +47,7 @@ Sorbet/EnforceSigilOrder:
|
||||
Sorbet/EnforceSingleSigil:
|
||||
Description: 'Ensures that there is only one Sorbet sigil in a file.'
|
||||
Enabled: true
|
||||
VersionAdded: '<<next>>'
|
||||
VersionAdded: 0.7.0
|
||||
|
||||
Sorbet/EnforceSignatures:
|
||||
Description: 'Ensures all methods have a valid signature.'
|
||||
@ -73,6 +78,7 @@ Sorbet/ForbidRBIOutsideOfAllowedPaths:
|
||||
Enabled: true
|
||||
VersionAdded: 0.6.1
|
||||
AllowedPaths:
|
||||
- "rbi/**"
|
||||
- "sorbet/rbi/**"
|
||||
Include:
|
||||
- "**/*.rbi"
|
||||
@ -150,6 +156,16 @@ Sorbet/OneAncestorPerLine:
|
||||
Enabled: false
|
||||
VersionAdded: '0.6.0'
|
||||
|
||||
Sorbet/RedundantExtendTSig:
|
||||
Description: >-
|
||||
Forbid the usage of redundant `extend T::Sig`.
|
||||
|
||||
Only for use in applications that monkey patch `Module.include(T::Sig)` directly,
|
||||
where it is useful to reduce noise.
|
||||
Enabled: false
|
||||
Safe: false
|
||||
VersionAdded: 0.7.0
|
||||
|
||||
Sorbet/SignatureBuildOrder:
|
||||
Description: >-
|
||||
Enforces the order of parts in a signature.
|
||||
@ -7,18 +7,18 @@ module RuboCop
|
||||
module Cop
|
||||
module Sorbet
|
||||
# This cop disallows use of `T.untyped` or `T.nilable(T.untyped)`
|
||||
# as a prop type for `T::Struct`.
|
||||
# as a prop type for `T::Struct` or `T::ImmutableStruct`.
|
||||
#
|
||||
# @example
|
||||
#
|
||||
# # bad
|
||||
# class SomeClass
|
||||
# class SomeClass < T::Struct
|
||||
# const :foo, T.untyped
|
||||
# prop :bar, T.nilable(T.untyped)
|
||||
# end
|
||||
#
|
||||
# # good
|
||||
# class SomeClass
|
||||
# class SomeClass < T::Struct
|
||||
# const :foo, Integer
|
||||
# prop :bar, T.nilable(String)
|
||||
# end
|
||||
@ -29,6 +29,10 @@ module RuboCop
|
||||
(const (const nil? :T) :Struct)
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :t_immutable_struct, <<~PATTERN
|
||||
(const (const nil? :T) :ImmutableStruct)
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :t_untyped, <<~PATTERN
|
||||
(send (const nil? :T) :untyped)
|
||||
PATTERN
|
||||
@ -38,7 +42,7 @@ module RuboCop
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :subclass_of_t_struct?, <<~PATTERN
|
||||
(class (const ...) #t_struct ...)
|
||||
(class (const ...) {#t_struct #t_immutable_struct} ...)
|
||||
PATTERN
|
||||
|
||||
def_node_search :untyped_props, <<~PATTERN
|
||||
@ -9,7 +9,7 @@ module RuboCop
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# * `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["sorbet/rbi/**"])
|
||||
# * `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["rbi/**", "sorbet/rbi/**"])
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -17,6 +17,7 @@ module RuboCop
|
||||
# # other_file.rbi
|
||||
#
|
||||
# # good
|
||||
# # rbi/external_interface.rbi
|
||||
# # sorbet/rbi/some_file.rbi
|
||||
# # sorbet/rbi/any/path/for/file.rbi
|
||||
class ForbidRBIOutsideOfAllowedPaths < RuboCop::Cop::Cop
|
||||
@ -0,0 +1,50 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module Sorbet
|
||||
# Forbids the use of redundant `extend T::Sig`. Only for use in
|
||||
# applications that monkey patch `Module.include(T::Sig)` globally,
|
||||
# which would make it redundant.
|
||||
#
|
||||
# @safety
|
||||
# This cop should not be enabled in applications that have not monkey
|
||||
# patched `Module`.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# class Example
|
||||
# extend T::Sig
|
||||
# sig { void }
|
||||
# def no_op; end
|
||||
# end
|
||||
#
|
||||
# # good
|
||||
# class Example
|
||||
# sig { void }
|
||||
# def no_op; end
|
||||
# end
|
||||
#
|
||||
class RedundantExtendTSig < RuboCop::Cop::Cop
|
||||
MSG = "Do not redundantly `extend T::Sig` when it is already included in all modules."
|
||||
RESTRICT_ON_SEND = [:extend].freeze
|
||||
|
||||
def_node_matcher :extend_t_sig?, <<~PATTERN
|
||||
(send _ :extend (const (const {nil? | cbase} :T) :Sig))
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
return unless extend_t_sig?(node)
|
||||
|
||||
add_offense(node)
|
||||
end
|
||||
|
||||
def autocorrect(node)
|
||||
lambda do |corrector|
|
||||
corrector.remove(node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -7,7 +7,7 @@ module RuboCop
|
||||
module Sorbet
|
||||
# This cop checks that the Sorbet sigil comes as the first magic comment in the file.
|
||||
#
|
||||
# The expected order for magic comments is: typed, (en)?coding, warn_indent then frozen_string_literal.
|
||||
# The expected order for magic comments is: (en)?coding, typed, warn_indent then frozen_string_literal.
|
||||
#
|
||||
# For example, the following bad ordering:
|
||||
#
|
||||
@ -25,7 +25,7 @@ module RuboCop
|
||||
# class Foo; end
|
||||
# ```
|
||||
#
|
||||
# Only `typed`, `(en)?coding`, `warn_indent` and `frozen_string_literal` magic comments are considered,
|
||||
# Only `(en)?coding`, `typed`, `warn_indent` and `frozen_string_literal` magic comments are considered,
|
||||
# other comments or magic comments are left in the same place.
|
||||
class EnforceSigilOrder < ValidSigil
|
||||
include RangeHelp
|
||||
@ -0,0 +1,57 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "signature_cop"
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module Sorbet
|
||||
# This cop checks for blank lines after signatures.
|
||||
#
|
||||
# It also suggests an autocorrect
|
||||
#
|
||||
# @example
|
||||
#
|
||||
# # bad
|
||||
# sig { void }
|
||||
#
|
||||
# def foo; end
|
||||
#
|
||||
# # good
|
||||
# sig { void }
|
||||
# def foo; end
|
||||
#
|
||||
class EmptyLineAfterSig < SignatureCop
|
||||
include RangeHelp
|
||||
|
||||
def on_signature(node)
|
||||
if (next_method(node).line - node.last_line) > 1
|
||||
location = source_range(processed_source.buffer, next_method(node).line - 1, 0)
|
||||
add_offense(node, location: location, message: "Extra empty line or comment detected")
|
||||
end
|
||||
end
|
||||
|
||||
def autocorrect(node)
|
||||
-> (corrector) do
|
||||
offending_range = node.source_range.with(
|
||||
begin_pos: node.source_range.end_pos + 1,
|
||||
end_pos: processed_source.buffer.line_range(next_method(node).line).begin_pos
|
||||
)
|
||||
corrector.remove(offending_range)
|
||||
clean_range = offending_range.source.split("\n").reject(&:empty?).join("\n")
|
||||
offending_line = processed_source.buffer.line_range(node.source_range.first_line)
|
||||
corrector.insert_before(offending_line, "#{clean_range}\n") unless clean_range.empty?
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def next_method(node)
|
||||
processed_source.tokens.find do |t|
|
||||
t.line >= node.last_line &&
|
||||
(t.type == :kDEF || t.text.start_with?("attr_"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -94,6 +94,8 @@ module RuboCop
|
||||
end
|
||||
|
||||
def call_chain(sig_child_node)
|
||||
return [] if sig_child_node.nil?
|
||||
|
||||
call_node = root_call(sig_child_node).first
|
||||
return [] unless call_node
|
||||
|
||||
@ -12,7 +12,11 @@ module RuboCop
|
||||
@registry = Cop.registry # So we can properly subclass this cop
|
||||
|
||||
def_node_matcher(:signature?, <<~PATTERN)
|
||||
(block (send #allowed_recv :sig) (args) ...)
|
||||
(block (send
|
||||
{nil? #with_runtime? #without_runtime?}
|
||||
:sig
|
||||
(sym :final)?
|
||||
) (args) ...)
|
||||
PATTERN
|
||||
|
||||
def_node_matcher(:with_runtime?, <<~PATTERN)
|
||||
@ -23,13 +27,6 @@ module RuboCop
|
||||
(const (const (const nil? :T) :Sig) :WithoutRuntime)
|
||||
PATTERN
|
||||
|
||||
def allowed_recv(recv)
|
||||
return true unless recv
|
||||
return true if with_runtime?(recv)
|
||||
return true if without_runtime?(recv)
|
||||
false
|
||||
end
|
||||
|
||||
def on_block(node)
|
||||
on_signature(node) if signature?(node)
|
||||
end
|
||||
@ -8,6 +8,7 @@ require_relative "sorbet/one_ancestor_per_line"
|
||||
require_relative "sorbet/callback_conditionals_binding"
|
||||
require_relative "sorbet/forbid_t_unsafe"
|
||||
require_relative "sorbet/forbid_t_untyped"
|
||||
require_relative "sorbet/redundant_extend_t_sig"
|
||||
require_relative "sorbet/type_alias_name"
|
||||
|
||||
require_relative "sorbet/rbi/forbid_extend_t_sig_helpers_in_shims"
|
||||
@ -19,6 +20,7 @@ require_relative "sorbet/signatures/checked_true_in_signature"
|
||||
require_relative "sorbet/signatures/keyword_argument_ordering"
|
||||
require_relative "sorbet/signatures/signature_build_order"
|
||||
require_relative "sorbet/signatures/enforce_signatures"
|
||||
require_relative "sorbet/signatures/empty_line_after_sig"
|
||||
|
||||
require_relative "sorbet/sigils/valid_sigil"
|
||||
require_relative "sorbet/sigils/has_sigil"
|
||||
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
module RuboCop
|
||||
module Sorbet
|
||||
VERSION = "0.6.11"
|
||||
VERSION = "0.7.0"
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user