Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: alloc→allocate/allocation deref→dereference ptr→pointer (#2427)
Andrew Dunbar8ab2bf21b937
diff --git a/harper-core/src/linting/phrase_set_corrections/mod.rs b/harper-core/src/linting/phrase_set_corrections/mod.rsindex f74068a37..88fa67fd1 100644--- a/harper-core/src/linting/phrase_set_corrections/mod.rs+++ b/harper-core/src/linting/phrase_set_corrections/mod.rs@@ -162,6 +162,15 @@ pub fn lint_group() -> LintGroup {"Expands the abbreviation `deps` to the full word `dependencies` for clarity.",LintKind::Style),+ "ExpandDeref" => (+ &[+ ("deref", "dereference"),+ ("derefs", "dereferences"),+ ],+ "Use `dereference` instead of `deref`",+ "Expands the abbreviation `deref` to the full word `dereference` for clarity.",+ LintKind::Style+ ),"ExpandParameter" => (&[("param", "parameter"),@@ -171,6 +180,15 @@ pub fn lint_group() -> LintGroup {"Expands the abbreviation `param` to the full word `parameter` for clarity.",LintKind::Style),+ "ExpandPointer" => (+ &[+ ("ptr", "pointer"),+ ("ptrs", "pointers"),+ ],+ "Use `pointer` instead of `ptr`",+ "Expands the abbreviation `ptr` to the full word `pointer` for clarity.",+ LintKind::Style+ ),"ExpandStandardInputAndOutput" => (&[("stdin", "standard input"),@@ -426,6 +444,15 @@ pub fn lint_group() -> LintGroup {"Corrects variants of `double-edged sword`.",LintKind::Spelling),+ "ExpandAlloc" => (+ &[+ (&["alloc"], &["allocate", "allocation"]),+ (&["allocs"], &["allocates", "allocations"]),+ ],+ "Use `allocate` or `allocation` instead of `alloc`",+ "Expands the abbreviation `alloc` to the full word `allocate` or `allocation` for clarity.",+ LintKind::Style+ ),"ExpandDecl" => (&[(&["decl"], &["declaration", "declarator"]),diff --git a/harper-core/src/linting/phrase_set_corrections/tests.rs b/harper-core/src/linting/phrase_set_corrections/tests.rsindex 89e273833..7bbacbeb6 100644--- a/harper-core/src/linting/phrase_set_corrections/tests.rs+++ b/harper-core/src/linting/phrase_set_corrections/tests.rs@@ -1,6 +1,6 @@use crate::linting::tests::{assert_good_and_bad_suggestions, assert_lint_count, assert_no_lints,- assert_nth_suggestion_result, assert_suggestion_result,+ assert_nth_suggestion_result, assert_suggestion_result, assert_top3_suggestion_result,};use super::lint_group;@@ -505,6 +505,26 @@ fn corrects_decls() {// ExpandDependency// -none-+// ExpandDereference++#[test]+fn expand_deref() {+ assert_suggestion_result(+ "Should raw pointer deref/projections have to be in-bounds?",+ lint_group(),+ "Should raw pointer dereference/projections have to be in-bounds?",+ );+}++#[test]+fn corrects_derefs() {+ assert_suggestion_result(+ "A contiguous-in-memory double-ended queue that derefs into a slice - gnzlbg/slice_deque.",+ lint_group(),+ "A contiguous-in-memory double-ended queue that dereferences into a slice - gnzlbg/slice_deque.",+ );+}+// ExpandParam#[test]@@ -525,6 +545,24 @@ fn corrects_params() {);}+// ExpandPointer++fn correct_ptr() {+ assert_suggestion_result(+ "How else would you construct a slice from a ptr and a length?",+ lint_group(),+ "How else would you construct a slice from a pointer and a length?",+ );+}++fn correct_ptrs() {+ assert_suggestion_result(+ "FixedBufferAllocator.free not freeing ptrs",+ lint_group(),+ "FixedBufferAllocator.free not freeing pointers",+ );+}+// ExpandSpecification// ExpandStandardInput@@ -1003,9 +1041,6 @@ fn fix_escape_goats() {}// WreakHavoc-// -none---// Many to many tests#[test]fn fix_wreck_havoc() {@@ -1043,6 +1078,8 @@ fn fix_wrecks_havoc() {);}+// Many to many tests+// AwaitFor#[test]@@ -1191,6 +1228,26 @@ fn correct_double_edged_space_plural() {);}+// ExpandAlloc++#[test]+fn corrects_allocs() {+ assert_top3_suggestion_result(+ "cmd/compile: avoid allocs by better tracking of literals for interface conversions and make",+ lint_group(),+ "cmd/compile: avoid allocations by better tracking of literals for interface conversions and make",+ );+}++#[test]+fn expand_alloc() {+ assert_top3_suggestion_result(+ "Used to find system libraries that alloc RWX regions on load.",+ lint_group(),+ "Used to find system libraries that allocate RWX regions on load.",+ );+}+// Expat#[test]