Skip to content

Commit 28526ca

Browse files
committed
Report the full match for the OAuth 2.0 rule
The self-match reported in issue #41 ("Use 'OAuth 2.0' instead of 'OAuth 2.0'") was fixed upstream in fec6b34, but that fix left the alternatives shortest-first. Regex alternation takes the first branch that matches, so "OAuth 2" matched only the bare "OAuth" alternative and the alert read "Use 'OAuth 2.0' instead of 'OAuth'" — applying which gives "OAuth 2.0 2". Ordering the alternatives longest-first makes each variant report the span it actually means. The inline (?i) is dropped as redundant: the rule sets ignorecase. Fixtures now cover OAuth 2.0 as a negative and OAuth 2, OAuth2, OAuth2.0, and Oauth as positives.
1 parent e3d36a4 commit 28526ca

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

Google/WordListCase.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ swap:
1515
"(?:e-mail|Email|E-mail)": email
1616
"(?:file ?path|path ?name)": path
1717
"(?:kill|terminate|abort)": stop|exit|cancel|end
18-
"(?i)\\bOauth\\b(?! 2\\.0)|\\bOauth2\\.0\\b|\\bOAuth ?2\\b(?!\\.0)": OAuth 2.0
18+
# Longest form first: with the shortest alternative leading, 'OAuth 2' matched
19+
# only 'OAuth', so applying the suggestion produced 'OAuth 2.0 2'. The rule is
20+
# already case-insensitive, so the inline (?i) is redundant. See issue #41.
21+
'\bOauth2\.0\b|\bOAuth ?2\b(?!\.0)|\bOauth\b(?! ?2)': OAuth 2.0
1922
"(?:ok|Okay)": OK|okay
2023
"(?:WiFi|wifi)": Wi-Fi
2124
'[\.]+apk': APK

fixtures/Terms/test.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ Look at the section above.
3131
I used my cell phone to make the call.
3232

3333
Please check back later.
34+
35+
We support OAuth 2.0 for authentication.
36+
37+
We support OAuth 2, OAuth2, OAuth2.0, and Oauth.

testdata/Terms.ct

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ test.md:29:21:Google.WordListCase:Use 'preceding' instead of 'above'.
1414
test.md:31:1:Google.FirstPerson:Avoid first-person pronouns such as 'I '.
1515
test.md:31:8:Google.FirstPerson:Avoid first-person pronouns such as 'my'.
1616
test.md:31:11:Google.WordListCase:Use 'phone' or 'mobile phone' instead of 'cell phone'.
17+
test.md:37:12:Google.WordListCase:Use 'OAuth 2.0' instead of 'OAuth 2'.
18+
test.md:37:21:Google.WordListCase:Use 'OAuth 2.0' instead of 'OAuth2'.
19+
test.md:37:29:Google.WordListCase:Use 'OAuth 2.0' instead of 'OAuth2.0'.
20+
test.md:37:43:Google.WordListCase:Use 'OAuth 2.0' instead of 'Oauth'.

0 commit comments

Comments
 (0)