Skip to content

feat: detect capitalized false positives #988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions harper-core/src/linting/adjective_of_a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ impl Linter for AdjectiveOfA {

// Rule out false positives

// "much of a" is a different and valid construction.
if adj_chars == ['m', 'u', 'c', 'h']
if match adj_chars {
// "much of a" is a different and valid construction.
['m', 'u', 'c', 'h'] | ['M', 'u', 'c', 'h'] => true,
// The word is used more as a noun in this context.
// (using .kind.is_likely_homograph() here is too strict)
|| adj_chars == ['k', 'i', 'n', 'd']
|| adj_chars == ['m', 'e', 'a', 'n', 'i', 'n', 'g']
|| adj_chars == ['p', 'a', 'r', 't']
{
['f', 'r', 'o', 'n', 't'] | ['F', 'r', 'o', 'n', 't'] => true,
['k', 'i', 'n', 'd'] | ['K', 'i', 'n', 'd'] => true,
['m', 'e', 'a', 'n', 'i', 'n', 'g'] | ['M', 'e', 'a', 'n', 'i', 'n', 'g'] => true,
['p', 'a', 'r', 't'] | ['P', 'a', 'r', 't'] => true,
// TODO: consider "more of a" and "less of a"
_ => false,
} {
continue;
}

// Rule out comparatives and superlatives.

// Pros:
Expand Down Expand Up @@ -176,4 +179,13 @@ mod tests {
0,
);
}

#[test]
fn dont_flag_false_positive_upper() {
assert_lint_count(
"Quarkus Extension as Part of a Project inside a Monorepo?",
AdjectiveOfA,
0,
);
}
}