diff --git a/Library/Homebrew/rubocops/shared/desc_helper.rb b/Library/Homebrew/rubocops/shared/desc_helper.rb index 63cc95537c..5e1e273c51 100644 --- a/Library/Homebrew/rubocops/shared/desc_helper.rb +++ b/Library/Homebrew/rubocops/shared/desc_helper.rb @@ -64,6 +64,10 @@ module RuboCop 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." unless 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." diff --git a/Library/Homebrew/test/rubocops/cask/desc_spec.rb b/Library/Homebrew/test/rubocops/cask/desc_spec.rb index 38793ccf99..8b06c40a12 100644 --- a/Library/Homebrew/test/rubocops/cask/desc_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/desc_spec.rb @@ -63,4 +63,40 @@ describe RuboCop::Cop::Cask::Desc do 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