Skip to content

Commit

Permalink
style: fix path checking.
Browse files Browse the repository at this point in the history
- Add all necessary files to the path, using globs when necessary.
- Remove `Pathname` monkeypatch
  • Loading branch information
MikeMcQuaid committed Jun 12, 2024
1 parent 1fa25b2 commit 95b1679
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 0 additions & 5 deletions Library/Homebrew/extend/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,6 @@ def dylib?
false
end

sig { returns(T::Boolean) }
def tap?
!Tap.from_path(self).nil?
end

sig { returns(T::Array[String]) }
def rpaths
[]
Expand Down
16 changes: 11 additions & 5 deletions Library/Homebrew/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def self.check_style_impl(files, output_type,
debug: false, verbose: false)
raise ArgumentError, "Invalid output type: #{output_type.inspect}" if [:print, :json].exclude?(output_type)

ruby_files = []
shell_files = []
actionlint_files = []
ruby_files = T.let([], T::Array[Pathname])
shell_files = T.let([], T::Array[Pathname])
actionlint_files = T.let([], T::Array[Pathname])
Array(files).map(&method(:Pathname))
.each do |path|
case path.extname
Expand All @@ -57,8 +57,14 @@ def self.check_style_impl(files, output_type,
when ".yml"
actionlint_files << path if path.realpath.to_s.include?("/.github/workflows/")
else
ruby_files << path if path.tap?
shell_files << path if path.realpath == HOMEBREW_BREW_FILE.realpath
ruby_files << path
shell_files += if [HOMEBREW_PREFIX, HOMEBREW_REPOSITORY].include?(path)

Check warning on line 61 in Library/Homebrew/style.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/style.rb#L61

Added line #L61 was not covered by tests
shell_scripts
else
path.glob("**/*.sh")
.reject { |path| path.to_s.include?("/vendor/") }

Check warning on line 65 in Library/Homebrew/style.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/style.rb#L65

Added line #L65 was not covered by tests
end
actionlint_files += (path/".github/workflows").glob("*.y{,a}ml")

Check warning on line 67 in Library/Homebrew/style.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/style.rb#L67

Added line #L67 was not covered by tests
end
end

Expand Down

0 comments on commit 95b1679

Please sign in to comment.