Skip to content

Commit

Permalink
Merge pull request #8557 from reitermarkus/desc-cop-macos
Browse files Browse the repository at this point in the history
Don't allow platform in cask descriptions.
  • Loading branch information
reitermarkus authored Sep 1, 2020
2 parents 1431dda + f32b2e0 commit 50a9907
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Library/Homebrew/rubocops/shared/desc_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def audit_desc(type, name, desc_call)
name_regex = name.delete("-").split("").join('[\s\-]?')
problem "Description shouldn't start with the #{type} name." if regex_match_group(desc, /^#{name_regex}\b/i)

if type == :cask && match = regex_match_group(desc, /\b(macOS|Mac( ?OS( ?X)?)?|OS ?X)\b/i)
problem "Description shouldn't contain the platform." if match[1] != "MAC"
end

# Check if a full stop is used at the end of a desc (apart from in the case of "etc.").
if regex_match_group(desc, /\.$/) && !string_content(desc).end_with?("etc.")
problem "Description shouldn't end with a full stop."
Expand Down
36 changes: 36 additions & 0 deletions Library/Homebrew/test/rubocops/cask/desc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,40 @@
end
RUBY
end

it "does not contain the platform" do
expect_offense <<~RUBY, "/homebrew-cask/Casks/foo.rb"
cask 'foo-bar' do
desc 'macOS status bar monitor'
^^^^^ Description shouldn\'t contain the platform.
end
RUBY

expect_offense <<~RUBY, "/homebrew-cask/Casks/foo.rb"
cask 'foo-bar' do
desc 'Toggles dark mode on Mac OS Mojave'
^^^^^^ Description shouldn\'t contain the platform.
end
RUBY

expect_offense <<~RUBY, "/homebrew-cask/Casks/foo.rb"
cask 'foo-bar' do
desc 'Better input source switcher for OS X'
^^^^ Description shouldn\'t contain the platform.
end
RUBY

expect_offense <<~RUBY, "/homebrew-cask/Casks/foo.rb"
cask 'foo-bar' do
desc 'Media Manager for Mac OS X'
^^^^^^^^ Description shouldn\'t contain the platform.
end
RUBY

expect_no_offenses <<~RUBY
cask 'foo' do
desc 'MAC address changer'
end
RUBY
end
end

0 comments on commit 50a9907

Please sign in to comment.