Merge pull request #12541 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-sorbet-0.6.4
build(deps): bump rubocop-sorbet from 0.6.3 to 0.6.4 in /Library/Homebrew
This commit is contained in:
commit
6d0f534810
@ -144,7 +144,7 @@ GEM
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-rspec (2.6.0)
|
||||
rubocop (~> 1.19)
|
||||
rubocop-sorbet (0.6.3)
|
||||
rubocop-sorbet (0.6.4)
|
||||
rubocop (>= 0.90.0)
|
||||
ruby-macho (2.5.1)
|
||||
ruby-progressbar (1.11.0)
|
||||
|
||||
@ -151,7 +151,6 @@ class RuboCop::Cop::Sorbet::ForbidRBIOutsideOfAllowedPaths < ::RuboCop::Cop::Cop
|
||||
private
|
||||
|
||||
def allowed_paths; end
|
||||
def message; end
|
||||
end
|
||||
|
||||
class RuboCop::Cop::Sorbet::ForbidSuperclassConstLiteral < ::RuboCop::Cop::Cop
|
||||
@ -90,7 +90,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.23.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.12.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.12.4/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.6.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.3/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.4/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov_json_formatter-0.1.3/lib"
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module Sorbet
|
||||
# This cop makes sure that RBI files are always located under the defined allowed paths.
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# * `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["sorbet/rbi/**"])
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# # lib/some_file.rbi
|
||||
# # other_file.rbi
|
||||
#
|
||||
# # good
|
||||
# # sorbet/rbi/some_file.rbi
|
||||
# # sorbet/rbi/any/path/for/file.rbi
|
||||
class ForbidRBIOutsideOfAllowedPaths < RuboCop::Cop::Cop
|
||||
include RangeHelp
|
||||
|
||||
def investigate(processed_source)
|
||||
add_offense(
|
||||
nil,
|
||||
location: source_range(processed_source.buffer, 1, 0),
|
||||
message: message
|
||||
) if allowed_paths.none? { |pattern| File.fnmatch(pattern, processed_source.file_path) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def allowed_paths
|
||||
cop_config["AllowedPaths"]&.compact || []
|
||||
end
|
||||
|
||||
def message
|
||||
if allowed_paths.empty?
|
||||
"RBI files should be located in an allowed path, but AllowedPaths is empty or nil"
|
||||
else
|
||||
"RBI file path should match one of: #{allowed_paths.join(", ")}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,65 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "pathname"
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module Sorbet
|
||||
# This cop makes sure that RBI files are always located under the defined allowed paths.
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# * `AllowedPaths`: A list of the paths where RBI files are allowed (default: ["sorbet/rbi/**"])
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# # lib/some_file.rbi
|
||||
# # other_file.rbi
|
||||
#
|
||||
# # good
|
||||
# # sorbet/rbi/some_file.rbi
|
||||
# # sorbet/rbi/any/path/for/file.rbi
|
||||
class ForbidRBIOutsideOfAllowedPaths < RuboCop::Cop::Cop
|
||||
include RangeHelp
|
||||
|
||||
def investigate(processed_source)
|
||||
paths = allowed_paths
|
||||
|
||||
if paths.nil?
|
||||
add_offense(
|
||||
nil,
|
||||
location: source_range(processed_source.buffer, 1, 0),
|
||||
message: "AllowedPaths expects an array"
|
||||
)
|
||||
return
|
||||
elsif paths.empty?
|
||||
add_offense(
|
||||
nil,
|
||||
location: source_range(processed_source.buffer, 1, 0),
|
||||
message: "AllowedPaths cannot be empty"
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
# When executed the path to the source file is absolute.
|
||||
# We need to remove the exec path directory prefix before matching with the filename regular expressions.
|
||||
rel_path = processed_source.file_path.sub("#{Dir.pwd}/", "")
|
||||
|
||||
add_offense(
|
||||
nil,
|
||||
location: source_range(processed_source.buffer, 1, 0),
|
||||
message: "RBI file path should match one of: #{paths.join(", ")}"
|
||||
) if paths.none? { |pattern| File.fnmatch(pattern, rel_path) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def allowed_paths
|
||||
paths = cop_config["AllowedPaths"]
|
||||
return nil unless paths.is_a?(Array)
|
||||
paths.compact
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
module RuboCop
|
||||
module Sorbet
|
||||
VERSION = "0.6.3"
|
||||
VERSION = "0.6.4"
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user