Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat: level of details→level of detail/levels of detail (#3486)

Andrew Dunbar18d12c9fb3e8
diff --git a/harper-core/default_config.json b/harper-core/default_config.json
index 187ee6bc1..c8eca2861 100644
--- a/harper-core/default_config.json
+++ b/harper-core/default_config.json
@@ -3329,6 +3329,13 @@
"label": "Plural Wrong Word Of Phrase"
}
},
+ {
+ "Bool": {
+ "name": "LevelOfDetails",
+ "state": true,
+ "label": "Level of Details"
+ }
+ },
{
"Bool": {
"name": "ProgressiveNeedsBe",
diff --git a/harper-core/src/linting/phrase_set_corrections/mod.rs b/harper-core/src/linting/phrase_set_corrections/mod.rs
index 97f00b3c9..c5edff1dc 100644
--- a/harper-core/src/linting/phrase_set_corrections/mod.rs
+++ b/harper-core/src/linting/phrase_set_corrections/mod.rs
@@ -865,6 +865,16 @@ pub fn lint_group() -> LintGroup {
"Corrects `how ... looks like` to `how ... looks` or `what ... looks like`.",
LintKind::Grammar
),
+ "LevelOfDetails" => (
+ &[
+ (&["level of details"], &["level of detail", "levels of detail"]),
+ (&["level-of-details"], &["level-of-detail", "levels-of-details"]),
+ (&["levels of details"], &["levels of detail"])
+ ],
+ "For multiple levels, pluralize `level` instead of `detail`. `Detail` remains singular whether one or multiple levels.",
+ "Corrects `level of details` to `level of detail` or `levels of detail`.",
+ LintKind::Usage
+ ),
"MakeItSeem" => (
&[
(&["make it seems"], &["make it seem"]),
diff --git a/harper-core/src/linting/phrase_set_corrections/tests.rs b/harper-core/src/linting/phrase_set_corrections/tests.rs
index f8431d7ff..4391c6cf8 100644
--- a/harper-core/src/linting/phrase_set_corrections/tests.rs
+++ b/harper-core/src/linting/phrase_set_corrections/tests.rs
@@ -2876,6 +2876,53 @@ fn correct_how_it_looks_like_with_apostrophe() {
);
}
+// LevelOfDetails
+
+#[test]
+fn corrects_level_of_details_singular_contrived() {
+ assert_suggestion_result(
+ "The model has a high level of details.",
+ lint_group(),
+ "The model has a high level of detail.",
+ );
+}
+
+#[test]
+fn corrects_levels_of_details_plural_contrived() {
+ assert_suggestion_result(
+ "The game uses several level of details to save memory.",
+ lint_group(),
+ "The game uses several levels of detail to save memory.",
+ );
+}
+
+#[test]
+fn corrects_level_of_details_singular_real_world() {
+ assert_suggestion_result(
+ "How to implement a level of details visualizer for 3D meshes?",
+ lint_group(),
+ "How to implement a level of detail visualizer for 3D meshes?",
+ );
+}
+
+#[test]
+fn corrects_level_of_details_plural_real_world() {
+ assert_suggestion_result(
+ "LOD's (Level of details) are a set of lower models used for the purpose of optimisation",
+ lint_group(),
+ "LOD's (Levels of detail) are a set of lower models used for the purpose of optimisation",
+ );
+}
+
+#[test]
+fn corrects_levels_of_details_real_world() {
+ assert_suggestion_result(
+ "The file completion uses two levels of details to optimize performance.",
+ lint_group(),
+ "The file completion uses two levels of detail to optimize performance.",
+ );
+}
+
// MakeItSeem
#[test]