-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17562 from reitermarkus/token-auditor
Share code between cask token and formula name audits.
- Loading branch information
Showing
5 changed files
with
66 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
module Homebrew | ||
class FormulaNameCaskTokenAuditor | ||
sig { returns(String) } | ||
attr_reader :token | ||
|
||
sig { params(token: String).void } | ||
def initialize(token) | ||
@token = token | ||
end | ||
|
||
sig { returns(T::Array[String]) } | ||
def errors | ||
errors = [] | ||
|
||
errors << "uppercase letters" if token.match?(/[A-Z]/) | ||
errors << "whitespace" if token.match?(/\s/) | ||
errors << "non-ASCII characters" unless token.ascii_only? | ||
errors << "double hyphens" if token.include?("--") | ||
|
||
errors << "a leading @" if token.start_with?("@") | ||
errors << "a trailing @" if token.end_with?("@") | ||
errors << "a leading hyphen" if token.start_with?("-") | ||
errors << "a trailing hyphen" if token.end_with?("-") | ||
|
||
errors << "multiple @ symbols" if token.count("@") > 1 | ||
|
||
errors << "a hyphen followed by an @" if token.include? "-@" | ||
errors << "an @ followed by a hyphen" if token.include? "@-" | ||
|
||
errors | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters