Merge pull request #8557 from reitermarkus/desc-cop-macos

Don't allow platform in cask descriptions.
This commit is contained in:
Markus Reiter 2020-09-01 14:42:05 +02:00 committed by GitHub
commit 50a9907591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View File

@ -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." 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."

View File

@ -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