Merge pull request #18824 from Homebrew/bump-cask-files-to-sorbet-strict
This commit is contained in:
commit
6fb9d2d2f4
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "utils/user"
|
require "utils/user"
|
||||||
@ -10,7 +10,7 @@ module Cask
|
|||||||
module Caskroom
|
module Caskroom
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def self.path
|
def self.path
|
||||||
@path ||= HOMEBREW_PREFIX/"Caskroom"
|
@path ||= T.let(HOMEBREW_PREFIX/"Caskroom", T.nilable(Pathname))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return all paths for installed casks.
|
# Return all paths for installed casks.
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "json"
|
require "json"
|
||||||
@ -12,24 +12,28 @@ module Cask
|
|||||||
#
|
#
|
||||||
# @api internal
|
# @api internal
|
||||||
class Config
|
class Config
|
||||||
DEFAULT_DIRS = {
|
DEFAULT_DIRS = T.let(
|
||||||
appdir: "/Applications",
|
{
|
||||||
keyboard_layoutdir: "/Library/Keyboard Layouts",
|
appdir: "/Applications",
|
||||||
colorpickerdir: "~/Library/ColorPickers",
|
keyboard_layoutdir: "/Library/Keyboard Layouts",
|
||||||
prefpanedir: "~/Library/PreferencePanes",
|
colorpickerdir: "~/Library/ColorPickers",
|
||||||
qlplugindir: "~/Library/QuickLook",
|
prefpanedir: "~/Library/PreferencePanes",
|
||||||
mdimporterdir: "~/Library/Spotlight",
|
qlplugindir: "~/Library/QuickLook",
|
||||||
dictionarydir: "~/Library/Dictionaries",
|
mdimporterdir: "~/Library/Spotlight",
|
||||||
fontdir: "~/Library/Fonts",
|
dictionarydir: "~/Library/Dictionaries",
|
||||||
servicedir: "~/Library/Services",
|
fontdir: "~/Library/Fonts",
|
||||||
input_methoddir: "~/Library/Input Methods",
|
servicedir: "~/Library/Services",
|
||||||
internet_plugindir: "~/Library/Internet Plug-Ins",
|
input_methoddir: "~/Library/Input Methods",
|
||||||
audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
|
internet_plugindir: "~/Library/Internet Plug-Ins",
|
||||||
vst_plugindir: "~/Library/Audio/Plug-Ins/VST",
|
audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
|
||||||
vst3_plugindir: "~/Library/Audio/Plug-Ins/VST3",
|
vst_plugindir: "~/Library/Audio/Plug-Ins/VST",
|
||||||
screen_saverdir: "~/Library/Screen Savers",
|
vst3_plugindir: "~/Library/Audio/Plug-Ins/VST3",
|
||||||
}.freeze
|
screen_saverdir: "~/Library/Screen Savers",
|
||||||
|
}.freeze,
|
||||||
|
T::Hash[Symbol, String],
|
||||||
|
)
|
||||||
|
|
||||||
|
sig { returns(T::Hash[Symbol, T.untyped]) }
|
||||||
def self.defaults
|
def self.defaults
|
||||||
{
|
{
|
||||||
languages: LazyObject.new { MacOS.languages },
|
languages: LazyObject.new { MacOS.languages },
|
||||||
@ -72,8 +76,13 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(config: T::Enumerable[[T.any(String, Symbol), T.any(String, Pathname, T::Array[String])]])
|
params(
|
||||||
.returns(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])])
|
config: T::Enumerable[
|
||||||
|
[T.any(String, Symbol), T.any(String, Pathname, T::Array[String])],
|
||||||
|
],
|
||||||
|
).returns(
|
||||||
|
T::Hash[Symbol, T.any(String, Pathname, T::Array[String])],
|
||||||
|
)
|
||||||
}
|
}
|
||||||
def self.canonicalize(config)
|
def self.canonicalize(config)
|
||||||
config.to_h do |k, v|
|
config.to_h do |k, v|
|
||||||
@ -104,9 +113,22 @@ module Cask
|
|||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
def initialize(default: nil, env: nil, explicit: {}, ignore_invalid_keys: false)
|
def initialize(default: nil, env: nil, explicit: {}, ignore_invalid_keys: false)
|
||||||
@default = self.class.canonicalize(self.class.defaults.merge(default)) if default
|
if default
|
||||||
@env = self.class.canonicalize(env) if env
|
@default = T.let(
|
||||||
@explicit = self.class.canonicalize(explicit)
|
self.class.canonicalize(self.class.defaults.merge(default)),
|
||||||
|
T.nilable(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if env
|
||||||
|
@env = T.let(
|
||||||
|
self.class.canonicalize(env),
|
||||||
|
T.nilable(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
@explicit = T.let(
|
||||||
|
self.class.canonicalize(explicit),
|
||||||
|
T::Hash[Symbol, T.any(String, Pathname, T::Array[String])],
|
||||||
|
)
|
||||||
|
|
||||||
if ignore_invalid_keys
|
if ignore_invalid_keys
|
||||||
@env&.delete_if { |key, _| self.class.defaults.keys.exclude?(key) }
|
@env&.delete_if { |key, _| self.class.defaults.keys.exclude?(key) }
|
||||||
@ -144,12 +166,12 @@ module Cask
|
|||||||
|
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def binarydir
|
def binarydir
|
||||||
@binarydir ||= HOMEBREW_PREFIX/"bin"
|
@binarydir ||= T.let(HOMEBREW_PREFIX/"bin", T.nilable(Pathname))
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def manpagedir
|
def manpagedir
|
||||||
@manpagedir ||= HOMEBREW_PREFIX/"share/man"
|
@manpagedir ||= T.let(HOMEBREW_PREFIX/"share/man", T.nilable(Pathname))
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Array[String]) }
|
sig { returns(T::Array[String]) }
|
||||||
@ -167,6 +189,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(languages: T::Array[String]).void }
|
||||||
def languages=(languages)
|
def languages=(languages)
|
||||||
explicit[:languages] = languages
|
explicit[:languages] = languages
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cask/artifact/relocated"
|
require "cask/artifact/relocated"
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
class List
|
class List
|
||||||
|
sig { params(casks: Cask, one: T::Boolean, full_name: T::Boolean, versions: T::Boolean).void }
|
||||||
def self.list_casks(*casks, one: false, full_name: false, versions: false)
|
def self.list_casks(*casks, one: false, full_name: false, versions: false)
|
||||||
output = if casks.any?
|
output = if casks.any?
|
||||||
casks.each do |cask|
|
casks.each do |cask|
|
||||||
@ -27,6 +28,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(cask: Cask).void }
|
||||||
def self.list_artifacts(cask)
|
def self.list_artifacts(cask)
|
||||||
cask.artifacts.group_by(&:class).sort_by { |klass, _| klass.english_name }.each do |klass, artifacts|
|
cask.artifacts.group_by(&:class).sort_by { |klass, _| klass.english_name }.each do |klass, artifacts|
|
||||||
next if [Artifact::Uninstall, Artifact::Zap].include? klass
|
next if [Artifact::Uninstall, Artifact::Zap].include? klass
|
||||||
@ -41,6 +43,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(cask: Cask).returns(String) }
|
||||||
def self.format_versioned(cask)
|
def self.format_versioned(cask)
|
||||||
"#{cask}#{cask.installed_version&.prepend(" ")}"
|
"#{cask}#{cask.installed_version&.prepend(" ")}"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,70 +1,81 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module RuboCop
|
module RuboCop
|
||||||
module Cask
|
module Cask
|
||||||
# Constants available globally for use in all cask cops.
|
# Constants available globally for use in all cask cops.
|
||||||
module Constants
|
module Constants
|
||||||
ON_SYSTEM_METHODS = [:arm, :intel, *MacOSVersion::SYMBOLS.keys].map { |option| :"on_#{option}" }.freeze
|
ON_SYSTEM_METHODS = T.let(
|
||||||
ON_SYSTEM_METHODS_STANZA_ORDER = [
|
[:arm, :intel, *MacOSVersion::SYMBOLS.keys].map { |option| :"on_#{option}" }.freeze,
|
||||||
:arm,
|
T::Array[Symbol],
|
||||||
:intel,
|
)
|
||||||
*MacOSVersion::SYMBOLS.reverse_each.to_h.keys, # Oldest OS blocks first since that's more common in Casks.
|
ON_SYSTEM_METHODS_STANZA_ORDER = T.let(
|
||||||
].map { |option, _| :"on_#{option}" }.freeze
|
|
||||||
|
|
||||||
STANZA_GROUPS = [
|
|
||||||
[:arch, :on_arch_conditional],
|
|
||||||
[:version, :sha256],
|
|
||||||
ON_SYSTEM_METHODS_STANZA_ORDER,
|
|
||||||
[:language],
|
|
||||||
[:url, :appcast, :name, :desc, :homepage],
|
|
||||||
[:livecheck],
|
|
||||||
[:deprecate!, :disable!],
|
|
||||||
[
|
[
|
||||||
:auto_updates,
|
:arm,
|
||||||
:conflicts_with,
|
:intel,
|
||||||
:depends_on,
|
*MacOSVersion::SYMBOLS.reverse_each.to_h.keys, # Oldest OS blocks first since that's more common in Casks.
|
||||||
:container,
|
].map { |option, _| :"on_#{option}" }.freeze,
|
||||||
],
|
T::Array[Symbol],
|
||||||
[
|
)
|
||||||
:suite,
|
|
||||||
:app,
|
|
||||||
:pkg,
|
|
||||||
:installer,
|
|
||||||
:binary,
|
|
||||||
:manpage,
|
|
||||||
:colorpicker,
|
|
||||||
:dictionary,
|
|
||||||
:font,
|
|
||||||
:input_method,
|
|
||||||
:internet_plugin,
|
|
||||||
:keyboard_layout,
|
|
||||||
:prefpane,
|
|
||||||
:qlplugin,
|
|
||||||
:mdimporter,
|
|
||||||
:screen_saver,
|
|
||||||
:service,
|
|
||||||
:audio_unit_plugin,
|
|
||||||
:vst_plugin,
|
|
||||||
:vst3_plugin,
|
|
||||||
:artifact,
|
|
||||||
:stage_only,
|
|
||||||
],
|
|
||||||
[:preflight],
|
|
||||||
[:postflight],
|
|
||||||
[:uninstall_preflight],
|
|
||||||
[:uninstall_postflight],
|
|
||||||
[:uninstall],
|
|
||||||
[:zap],
|
|
||||||
[:caveats],
|
|
||||||
].freeze
|
|
||||||
|
|
||||||
STANZA_GROUP_HASH =
|
STANZA_GROUPS = T.let(
|
||||||
|
[
|
||||||
|
[:arch, :on_arch_conditional],
|
||||||
|
[:version, :sha256],
|
||||||
|
ON_SYSTEM_METHODS_STANZA_ORDER,
|
||||||
|
[:language],
|
||||||
|
[:url, :appcast, :name, :desc, :homepage],
|
||||||
|
[:livecheck],
|
||||||
|
[:deprecate!, :disable!],
|
||||||
|
[
|
||||||
|
:auto_updates,
|
||||||
|
:conflicts_with,
|
||||||
|
:depends_on,
|
||||||
|
:container,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
:suite,
|
||||||
|
:app,
|
||||||
|
:pkg,
|
||||||
|
:installer,
|
||||||
|
:binary,
|
||||||
|
:manpage,
|
||||||
|
:colorpicker,
|
||||||
|
:dictionary,
|
||||||
|
:font,
|
||||||
|
:input_method,
|
||||||
|
:internet_plugin,
|
||||||
|
:keyboard_layout,
|
||||||
|
:prefpane,
|
||||||
|
:qlplugin,
|
||||||
|
:mdimporter,
|
||||||
|
:screen_saver,
|
||||||
|
:service,
|
||||||
|
:audio_unit_plugin,
|
||||||
|
:vst_plugin,
|
||||||
|
:vst3_plugin,
|
||||||
|
:artifact,
|
||||||
|
:stage_only,
|
||||||
|
],
|
||||||
|
[:preflight],
|
||||||
|
[:postflight],
|
||||||
|
[:uninstall_preflight],
|
||||||
|
[:uninstall_postflight],
|
||||||
|
[:uninstall],
|
||||||
|
[:zap],
|
||||||
|
[:caveats],
|
||||||
|
].freeze,
|
||||||
|
T::Array[T::Array[Symbol]],
|
||||||
|
)
|
||||||
|
|
||||||
|
STANZA_GROUP_HASH = T.let(
|
||||||
STANZA_GROUPS.each_with_object({}) do |stanza_group, hash|
|
STANZA_GROUPS.each_with_object({}) do |stanza_group, hash|
|
||||||
stanza_group.each { |stanza| hash[stanza] = stanza_group }
|
stanza_group.each { |stanza| hash[stanza] = stanza_group }
|
||||||
end.freeze
|
end.freeze,
|
||||||
|
T::Hash[Symbol, T::Array[Symbol]],
|
||||||
|
)
|
||||||
|
|
||||||
STANZA_ORDER = STANZA_GROUPS.flatten.freeze
|
STANZA_ORDER = T.let(STANZA_GROUPS.flatten.freeze, T::Array[Symbol])
|
||||||
|
|
||||||
UNINSTALL_METHODS_ORDER = [
|
UNINSTALL_METHODS_ORDER = [
|
||||||
:early_script,
|
:early_script,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module RuboCop
|
module RuboCop
|
||||||
@ -26,16 +26,31 @@ module RuboCop
|
|||||||
|
|
||||||
return unless block_node.cask_block?
|
return unless block_node.cask_block?
|
||||||
|
|
||||||
@file_path = processed_source.file_path
|
@file_path = T.let(processed_source.file_path, T.nilable(String))
|
||||||
|
|
||||||
cask_block = RuboCop::Cask::AST::CaskBlock.new(block_node, comments)
|
cask_block = RuboCop::Cask::AST::CaskBlock.new(block_node, comments)
|
||||||
on_cask(cask_block)
|
on_cask(cask_block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
cask_stanzas: T::Array[RuboCop::Cask::AST::Stanza],
|
||||||
|
).returns(
|
||||||
|
T::Array[RuboCop::Cask::AST::Stanza],
|
||||||
|
)
|
||||||
|
}
|
||||||
def on_system_methods(cask_stanzas)
|
def on_system_methods(cask_stanzas)
|
||||||
cask_stanzas.select(&:on_system_block?)
|
cask_stanzas.select(&:on_system_block?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
block_node: RuboCop::AST::BlockNode,
|
||||||
|
comments: T::Array[String],
|
||||||
|
).returns(
|
||||||
|
T::Array[RuboCop::Cask::AST::Stanza],
|
||||||
|
)
|
||||||
|
}
|
||||||
def inner_stanzas(block_node, comments)
|
def inner_stanzas(block_node, comments)
|
||||||
block_contents = block_node.child_nodes.select(&:begin_type?)
|
block_contents = block_node.child_nodes.select(&:begin_type?)
|
||||||
inner_nodes = block_contents.map(&:child_nodes).flatten.select(&:send_type?)
|
inner_nodes = block_contents.map(&:child_nodes).flatten.select(&:send_type?)
|
||||||
@ -44,7 +59,7 @@ module RuboCop
|
|||||||
|
|
||||||
sig { returns(T.nilable(String)) }
|
sig { returns(T.nilable(String)) }
|
||||||
def cask_tap
|
def cask_tap
|
||||||
return unless (match_obj = @file_path.match(%r{/(homebrew-\w+)/}))
|
return unless (match_obj = @file_path&.match(%r{/(homebrew-\w+)/}))
|
||||||
|
|
||||||
match_obj[1]
|
match_obj[1]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module RuboCop
|
module RuboCop
|
||||||
@ -7,6 +7,7 @@ module RuboCop
|
|||||||
class SharedFilelistGlob < Base
|
class SharedFilelistGlob < Base
|
||||||
extend AutoCorrector
|
extend AutoCorrector
|
||||||
|
|
||||||
|
sig { params(node: RuboCop::AST::SendNode).void }
|
||||||
def on_send(node)
|
def on_send(node)
|
||||||
return if node.method_name != :zap
|
return if node.method_name != :zap
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user