From 87e5fedc160776586f6d1c600b36ea6b78daed2e Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sat, 10 Aug 2024 00:00:49 +0100 Subject: [PATCH] metafiles: Bump to Sorbet `typed: strict` --- Library/Homebrew/metafiles.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/metafiles.rb b/Library/Homebrew/metafiles.rb index 9f3a74239f..a321874cf2 100644 --- a/Library/Homebrew/metafiles.rb +++ b/Library/Homebrew/metafiles.rb @@ -1,27 +1,33 @@ -# typed: true +# typed: strict # frozen_string_literal: true # Helper for checking if a file is considered a metadata file. module Metafiles - LICENSES = Set.new(%w[copying copyright license licence]).freeze + LICENSES = T.let(Set.new(%w[copying copyright license licence]).freeze, T::Set[String]) # {https://github.com/github/markup#markups} - EXTENSIONS = Set.new(%w[ + EXTENSIONS = T.let(Set.new(%w[ .adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn .org .pod .rdoc .rst .rtf .textile .txt .wiki - ]).freeze - BASENAMES = Set.new(%w[about authors changelog changes history news notes notice readme todo]).freeze + ]).freeze, T::Set[String]) + BASENAMES = T.let(Set.new(%w[ + about authors changelog changes history news notes notice readme todo + ]).freeze, T::Set[String]) module_function + sig { params(file: String).returns(T::Boolean) } def list?(file) return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file) !copy?(file) end + sig { params(file: String).returns(T::Boolean) } def copy?(file) file = file.downcase - return true if LICENSES.include? file.split(/\.|-/).first + license = file.split(/\.|-/).first + return false unless license + return true if LICENSES.include?(license) ext = File.extname(file) file = File.basename(file, ext) if EXTENSIONS.include?(ext)