Skip to content

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

fix: `just printaffixes` got broken (#1460)

Andrew Dunbarbfdf2b59a732
diff --git a/harper-cli/src/main.rs b/harper-cli/src/main.rs
index 1539cd9ff..851cf94a3 100644
--- a/harper-cli/src/main.rs
+++ b/harper-cli/src/main.rs
@@ -199,7 +199,7 @@ fn main() -> anyhow::Result<()> {
for token in doc.tokens() {
let json = serde_json::to_string(&token)?;
- println!("{}", json);
+ println!("{json}");
}
Ok(())
@@ -256,7 +256,7 @@ fn main() -> anyhow::Result<()> {
word_str.clear();
word_str.extend(word);
- println!("{:?}", word_str);
+ println!("{word_str:?}");
}
Ok(())
@@ -300,14 +300,10 @@ fn main() -> anyhow::Result<()> {
let summary = match &entry_in_dict {
Some((dict_word, dict_annot)) => {
let mut status_summary = if dict_annot.is_empty() {
- format!(
- "'{}' is already in the dictionary but not annotated.",
- dict_word
- )
+ format!("'{dict_word}' is already in the dictionary but not annotated.")
} else {
format!(
- "'{}' is already in the dictionary with annotation `{}`.",
- dict_word, dict_annot
+ "'{dict_word}' is already in the dictionary with annotation `{dict_annot}`."
)
};
@@ -323,7 +319,7 @@ fn main() -> anyhow::Result<()> {
status_summary
}
- None => format!("'{}' is not in the dictionary yet.", word),
+ None => format!("'{word}' is not in the dictionary yet."),
};
println!("{summary}");
@@ -454,18 +450,24 @@ fn main() -> anyhow::Result<()> {
let affixes_string = fs::read_to_string(&affixes_path)
.map_err(|e| anyhow!("Failed to read affixes.json: {e}"))?;
- let mut affixes_json: Value = serde_json::from_str(&affixes_string)
+ let affixes_json: Value = serde_json::from_str(&affixes_string)
.map_err(|e| anyhow!("Failed to parse affixes.json: {e}"))?;
// Get the nested "affixes" object
- let affixes_obj = affixes_json
- .get_mut("affixes")
- .and_then(Value::as_object_mut)
+ let affixes_obj = &affixes_json
+ .get("affixes")
+ .and_then(Value::as_object)
.ok_or_else(|| anyhow!("affixes.json does not contain 'affixes' object"))?;
+ let properties_obj = &affixes_json
+ .get("properties")
+ .and_then(Value::as_object)
+ .ok_or_else(|| anyhow!("affixes.json does not contain 'properties' object"))?;
+
// Validate old flag exists and get its description
let old_entry = affixes_obj
.get(&old)
+ .or_else(|| properties_obj.get(&old))
.ok_or_else(|| anyhow!("Flag '{old}' not found in affixes.json"))?;
let description = old_entry
@@ -476,7 +478,7 @@ fn main() -> anyhow::Result<()> {
println!("Renaming flag '{old}' ({description})");
// Validate new flag doesn't exist
- if let Some(new_entry) = affixes_obj.get(&new) {
+ if let Some(new_entry) = affixes_obj.get(&new).or_else(|| properties_obj.get(&new)) {
let new_desc = new_entry
.get("#")
.and_then(Value::as_str)
@@ -584,9 +586,9 @@ fn main() -> anyhow::Result<()> {
// Instead of moving `results` into the for loop, iterate over a reference to it
for (normalized, originals) in &results {
- println!("\nVariants for '{}':", normalized);
+ println!("\nVariants for '{normalized}':");
for original in originals {
- println!(" - {}", original);
+ println!(" - {original}");
}
}
@@ -659,11 +661,11 @@ fn print_word_derivations(word: &str, annot: &str, dictionary: &impl Dictionary)
.words_iter()
.filter(|e| dictionary.get_word_metadata(e).unwrap().derived_from == Some(id));
- println!(" - {}", word);
+ println!(" - {word}");
for child in children {
let child_str: String = child.iter().collect();
- println!(" - {}", child_str);
+ println!(" - {child_str}");
}
}
diff --git a/harper-core/src/currency.rs b/harper-core/src/currency.rs
index 4ddc39b54..413f6868c 100644
--- a/harper-core/src/currency.rs
+++ b/harper-core/src/currency.rs
@@ -68,16 +68,16 @@ impl Currency {
let amount = amount.to_string();
match self {
- Currency::Dollar => format!("{}{amount}", c),
- Currency::Cent => format!("{amount}{}", c),
- Currency::Euro => format!("{}{amount}", c),
- Currency::Ruble => format!("{amount} {}", c),
- Currency::Lira => format!("{amount} {}", c),
- Currency::Pound => format!("{}{amount}", c),
- Currency::Yen => format!("{} {amount}", c),
- Currency::Baht => format!("{amount} {}", c),
- Currency::Won => format!("{} {amount}", c),
- Currency::Kip => format!("{}{amount}", c),
+ Currency::Dollar => format!("{c}{amount}"),
+ Currency::Cent => format!("{amount}{c}"),
+ Currency::Euro => format!("{c}{amount}"),
+ Currency::Ruble => format!("{amount} {c}"),
+ Currency::Lira => format!("{amount} {c}"),
+ Currency::Pound => format!("{c}{amount}"),
+ Currency::Yen => format!("{c} {amount}"),
+ Currency::Baht => format!("{amount} {c}"),
+ Currency::Won => format!("{c} {amount}"),
+ Currency::Kip => format!("{c}{amount}"),
}
}
}
diff --git a/harper-core/src/expr/spelled_number_expr.rs b/harper-core/src/expr/spelled_number_expr.rs
index 266e466c6..5ba2442ea 100644
--- a/harper-core/src/expr/spelled_number_expr.rs
+++ b/harper-core/src/expr/spelled_number_expr.rs
@@ -124,7 +124,7 @@ mod tests {
.iter()
.map(|t| doc.get_span_content_str(&t.span))
.collect();
- println!("- '{}' (span: {:?})", text, m);
+ println!("- '{text}' (span: {m:?})");
}
assert_eq!(matches.len(), 2);
diff --git a/harper-core/src/linting/boring_words.rs b/harper-core/src/linting/boring_words.rs
index 0aa3e1ffd..11e838d96 100644
--- a/harper-core/src/linting/boring_words.rs
+++ b/harper-core/src/linting/boring_words.rs
@@ -36,8 +36,7 @@ impl ExprLinter for BoringWords {
lint_kind: LintKind::Enhancement,
suggestions: vec![],
message: format!(
- "“{}” is a boring word. Try something a little more exotic.",
- matched_word
+ "“{matched_word}” is a boring word. Try something a little more exotic."
),
priority: 127,
})
diff --git a/harper-core/src/linting/everyday.rs b/harper-core/src/linting/everyday.rs
index 44be3ea0b..4242506ae 100644
--- a/harper-core/src/linting/everyday.rs
+++ b/harper-core/src/linting/everyday.rs
@@ -221,7 +221,7 @@ impl ExprLinter for Everyday {
replacement,
span.get_content(src),
)],
- message: format!("You probably mean the {} `{}` here.", pos, replacement),
+ message: format!("You probably mean the {pos} `{replacement}` here."),
priority: 31,
})
}
diff --git a/harper-core/src/linting/expand_time_shorthands.rs b/harper-core/src/linting/expand_time_shorthands.rs
index 7051cc9ec..28edca919 100644
--- a/harper-core/src/linting/expand_time_shorthands.rs
+++ b/harper-core/src/linting/expand_time_shorthands.rs
@@ -90,7 +90,7 @@ impl ExprLinter for ExpandTimeShorthands {
span: offending_span,
lint_kind: LintKind::WordChoice,
suggestions: vec![Suggestion::ReplaceWith(replacement_chars)],
- message: format!("Did you mean `{}`?", replacement),
+ message: format!("Did you mean `{replacement}`?"),
priority: 31,
})
}
diff --git a/harper-core/src/linting/hyphenate_number_day.rs b/harper-core/src/linting/hyphenate_number_day.rs
index 88119672d..e3b02183a 100644
--- a/harper-core/src/linting/hyphenate_number_day.rs
+++ b/harper-core/src/linting/hyphenate_number_day.rs
@@ -49,10 +49,7 @@ impl ExprLinter for HyphenateNumberDay {
span: space.span,
lint_kind: LintKind::Miscellaneous,
suggestions: vec![Suggestion::ReplaceWith(vec!['-'])],
- message: format!(
- "Use a hyphen in `{}-day` when forming an adjectival compound.",
- number
- ),
+ message: format!("Use a hyphen in `{number}-day` when forming an adjectival compound."),
priority: 31,
})
}
diff --git a/harper-core/src/linting/less_worse.rs b/harper-core/src/linting/less_worse.rs
index 0a99728f9..33f1b4607 100644
--- a/harper-core/src/linting/less_worse.rs
+++ b/harper-core/src/linting/less_worse.rs
@@ -111,9 +111,9 @@ mod tests {
"Maybe downstream packaging folks could advice what would be least worse option.",
LessWorse::default(),
&[
- &"Maybe downstream packaging folks could advice what would be least worst option.",
- &"Maybe downstream packaging folks could advice what would be least bad option.",
- &"Maybe downstream packaging folks could advice what would be less bad option.",
+ "Maybe downstream packaging folks could advice what would be least worst option.",
+ "Maybe downstream packaging folks could advice what would be least bad option.",
+ "Maybe downstream packaging folks could advice what would be less bad option.",
],
&[],
);
@@ -125,8 +125,8 @@ mod tests {
"async-dropper is probably the least-worst ad-hoc AsyncDrop implementation you've seen.",
LessWorse::default(),
&[
- &"async-dropper is probably the least worst ad-hoc AsyncDrop implementation you've seen.",
- &"async-dropper is probably the least bad ad-hoc AsyncDrop implementation you've seen.",
+ "async-dropper is probably the least worst ad-hoc AsyncDrop implementation you've seen.",
+ "async-dropper is probably the least bad ad-hoc AsyncDrop implementation you've seen.",
],
&[],
);
@@ -147,8 +147,8 @@ mod tests {
"May be the less worst choice for some little playlists.",
LessWorse::default(),
&[
- &"May be the less bad choice for some little playlists.",
- &"May be the least bad choice for some little playlists.",
+ "May be the less bad choice for some little playlists.",
+ "May be the least bad choice for some little playlists.",
],
&[],
);
diff --git a/harper-core/src/linting/lint_kind.rs b/harper-core/src/linting/lint_kind.rs
index 16e2cf41b..0a0bea429 100644
--- a/harper-core/src/linting/lint_kind.rs
+++ b/harper-core/src/linting/lint_kind.rs
@@ -75,6 +75,6 @@ impl Display for LintKind {
LintKind::WordChoice => "Word Choice",
};
- write!(f, "{}", s)
+ write!(f, "{s}")
}
}
diff --git a/harper-core/src/linting/long_sentences.rs b/harper-core/src/linting/long_sentences.rs
index ebe33d775..fe7fb73a5 100644
--- a/harper-core/src/linting/long_sentences.rs
+++ b/harper-core/src/linting/long_sentences.rs
@@ -20,7 +20,7 @@ impl Linter for LongSentences {
sentence.last().unwrap().span.end,
),
lint_kind: LintKind::Readability,
- message: format!("This sentence is {} words long.", word_count),
+ message: format!("This sentence is {word_count} words long."),
..Default::default()
})
}
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index 4444486f8..7247e377f 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -225,6 +225,8 @@ where
#[cfg(test)]
pub mod tests {
+ use hashbrown::HashSet;
+
use super::Linter;
use crate::{Document, FstDictionary, parsers::PlainEnglish};
@@ -331,10 +333,9 @@ pub mod tests {
if suggestion_text == bad_suggestion {
panic!(
- "Found undesired suggestion at lint[{}].suggestions[{}]:\n\
- Expected to not find suggestion: \"{}\"\n\
- But found: \"{}\"",
- i, j, bad_suggestion, suggestion_text
+ "Found undesired suggestion at lint[{i}].suggestions[{j}]:\n\
+ Expected to not find suggestion: \"{bad_suggestion}\"\n\
+ But found: \"{suggestion_text}\""
);
}
}
@@ -353,7 +354,7 @@ pub mod tests {
let test = Document::new_markdown_default_curated(text);
let lints = linter.lint(&test);
- let mut unseen_good: std::collections::HashSet<_> = good.iter().cloned().collect();
+ let mut unseen_good: HashSet<_> = good.iter().cloned().collect();
let mut found_bad = Vec::new();
let mut found_good = Vec::new();
@@ -367,16 +368,14 @@ pub mod tests {
if bad.contains(&&*suggestion_text) {
found_bad.push((i, j, suggestion_text.clone()));
eprintln!(
- " ❌ Found bad suggestion at lint[{}].suggestions[{}]: \"{}\"",
- i, j, suggestion_text
+ " ❌ Found bad suggestion at lint[{i}].suggestions[{j}]: \"{suggestion_text}\""
);
}
// Check for good suggestions
else if good.contains(&&*suggestion_text) {
found_good.push((i, j, suggestion_text.clone()));
eprintln!(
- " ✅ Found good suggestion at lint[{}].suggestions[{}]: \"{}\"",
- i, j, suggestion_text
+ " ✅ Found good suggestion at lint[{i}].suggestions[{j}]: \"{suggestion_text}\""
);
unseen_good.remove(suggestion_text.as_str());
}
@@ -391,7 +390,7 @@ pub mod tests {
if !found_bad.is_empty() {
eprintln!("\n❌ Found {} bad suggestions:", found_bad.len());
for (i, j, text) in &found_bad {
- eprintln!(" - lint[{}].suggestions[{}]: \"{}\"", i, j, text);
+ eprintln!(" - lint[{i}].suggestions[{j}]: \"{text}\"");
}
}
@@ -402,7 +401,7 @@ pub mod tests {
unseen_good.len()
);
for text in &unseen_good {
- eprintln!(" - \"{}\"", text);
+ eprintln!(" - \"{text}\"");
}
}
@@ -453,7 +452,7 @@ pub mod tests {
}
}
- eprintln!("Corrected {} times.", iter_count);
+ eprintln!("Corrected {iter_count} times.");
text_chars.iter().collect()
}
diff --git a/harper-core/src/linting/modal_of.rs b/harper-core/src/linting/modal_of.rs
index 89ec75df0..44e9f955c 100644
--- a/harper-core/src/linting/modal_of.rs
+++ b/harper-core/src/linting/modal_of.rs
@@ -18,7 +18,7 @@ impl Default for ModalOf {
let modals = ["could", "might", "must", "should", "would"];
let mut words = WordSet::new(&modals);
modals.iter().for_each(|word| {
- words.add(&format!("{}n't", word));
+ words.add(&format!("{word}n't"));
});
let modal_of = Lrc::new(
diff --git a/harper-core/src/linting/most_number.rs b/harper-core/src/linting/most_number.rs
index a63c93edf..446c8f82e 100644
--- a/harper-core/src/linting/most_number.rs
+++ b/harper-core/src/linting/most_number.rs
@@ -51,7 +51,7 @@ impl ExprLinter for MostNumber {
.into_iter()
.map(|superlative| {
Suggestion::replace_with_match_case(
- format!("{} {}", superlative, noun_string).chars().collect(),
+ format!("{superlative} {noun_string}").chars().collect(),
most_amt_num_span.get_content(source),
)
})
diff --git a/harper-core/src/linting/noun_instead_of_verb.rs b/harper-core/src/linting/noun_instead_of_verb.rs
index 9550c2d4a..bd16024e2 100644
--- a/harper-core/src/linting/noun_instead_of_verb.rs
+++ b/harper-core/src/linting/noun_instead_of_verb.rs
@@ -134,7 +134,7 @@ impl ExprLinter for NounInsteadOfVerb {
verb.chars().collect(),
noun_chars,
)],
- message: format!("`{}` is a noun, the verb should be `{}`.", noun_text, verb),
+ message: format!("`{noun_text}` is a noun, the verb should be `{verb}`."),
priority: 63,
})
}
diff --git a/harper-core/src/linting/open_compounds.rs b/harper-core/src/linting/open_compounds.rs
index 4a4cd800a..2764121f3 100644
--- a/harper-core/src/linting/open_compounds.rs
+++ b/harper-core/src/linting/open_compounds.rs
@@ -106,7 +106,7 @@ impl ExprLinter for OpenCompounds {
phrase.chars().collect(),
span.get_content(source_chars),
)],
- message: format!("`{}` should be written as two words.", phrase),
+ message: format!("`{phrase}` should be written as two words."),
priority: 31,
})
}
diff --git a/harper-core/src/linting/oxymorons.rs b/harper-core/src/linting/oxymorons.rs
index ed3bd56fd..387665100 100644
--- a/harper-core/src/linting/oxymorons.rs
+++ b/harper-core/src/linting/oxymorons.rs
@@ -62,7 +62,7 @@ impl ExprLinter for Oxymorons {
span,
lint_kind: LintKind::Miscellaneous,
suggestions: Vec::new(),
- message: format!("'{}' is an oxymoron.", matched_text),
+ message: format!("'{matched_text}' is an oxymoron."),
priority: 31,
})
}
diff --git a/harper-core/src/linting/spaces.rs b/harper-core/src/linting/spaces.rs
index 28fc5803e..642e06653 100644
--- a/harper-core/src/linting/spaces.rs
+++ b/harper-core/src/linting/spaces.rs
@@ -21,8 +21,7 @@ impl Linter for Spaces {
lint_kind: LintKind::Formatting,
suggestions: vec![Suggestion::ReplaceWith(vec![' '])],
message: format!(
- "There are {} spaces where there should be only one.",
- count
+ "There are {count} spaces where there should be only one."
),
priority: 15,
})
diff --git a/harper-core/src/linting/throw_rubbish.rs b/harper-core/src/linting/throw_rubbish.rs
index d1325e11e..079b30da8 100644
--- a/harper-core/src/linting/throw_rubbish.rs
+++ b/harper-core/src/linting/throw_rubbish.rs
@@ -93,10 +93,7 @@ impl Linter for ThrowRubbish {
let suggestions = ["away", "out"]
.iter()
.flat_map(|adv| {
- [
- format!("{} {}{}", verb, adv, rest),
- format!("{}{} {}", verb, rest, adv),
- ]
+ [format!("{verb} {adv}{rest}"), format!("{verb}{rest} {adv}")]
})
.map(|sugg| Suggestion::ReplaceWith(sugg.chars().collect()))
.collect();
diff --git a/harper-core/src/linting/was_aloud.rs b/harper-core/src/linting/was_aloud.rs
index b486d1ad8..fde4bf5c5 100644
--- a/harper-core/src/linting/was_aloud.rs
+++ b/harper-core/src/linting/was_aloud.rs
@@ -35,7 +35,7 @@ impl ExprLinter for WasAloud {
span: matched_tokens.span()?,
lint_kind: LintKind::WordChoice,
suggestions: vec![Suggestion::replace_with_match_case(
- format!("{} allowed", verb).chars().collect(),
+ format!("{verb} allowed").chars().collect(),
matched_tokens[0].span.get_content(source),
)],
message: format!("Did you mean `{verb} allowed`?"),
diff --git a/harper-core/src/number.rs b/harper-core/src/number.rs
index 03316e2d0..b550db3a9 100644
--- a/harper-core/src/number.rs
+++ b/harper-core/src/number.rs
@@ -22,7 +22,7 @@ impl Display for Number {
if let Some(suffix) = self.suffix {
for c in suffix.to_chars() {
- write!(f, "{}", c)?;
+ write!(f, "{c}")?;
}
}
diff --git a/harper-core/src/span.rs b/harper-core/src/span.rs
index 4c93f9891..7e3c54dae 100644
--- a/harper-core/src/span.rs
+++ b/harper-core/src/span.rs
@@ -16,7 +16,7 @@ pub struct Span {
impl Span {
pub fn new(start: usize, end: usize) -> Self {
if start > end {
- panic!("{} > {}", start, end);
+ panic!("{start} > {end}");
}
Self { start, end }
}
diff --git a/harper-core/src/spell/rune/matcher.rs b/harper-core/src/spell/rune/matcher.rs
index 3b707b817..b3a6bb3d6 100644
--- a/harper-core/src/spell/rune/matcher.rs
+++ b/harper-core/src/spell/rune/matcher.rs
@@ -74,12 +74,12 @@ impl Display for Matcher {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
for op in &self.operators {
match op {
- Operator::Literal(c) => write!(f, "{}", c)?,
+ Operator::Literal(c) => write!(f, "{c}")?,
Operator::MatchOne(cs) => {
write!(f, "[")?;
for c in cs {
- write!(f, "{}", c)?;
+ write!(f, "{c}")?;
}
write!(f, "]")?;
@@ -88,7 +88,7 @@ impl Display for Matcher {
write!(f, "[^")?;
for c in cs {
- write!(f, "{}", c)?;
+ write!(f, "{c}")?;
}
write!(f, "]")?;
diff --git a/harper-core/src/word_metadata.rs b/harper-core/src/word_metadata.rs
index bf55f9053..bc44be9b5 100644
--- a/harper-core/src/word_metadata.rs
+++ b/harper-core/src/word_metadata.rs
@@ -807,7 +807,7 @@ mod tests {
fn md(word: &str) -> WordMetadata {
FstDictionary::curated()
.get_word_metadata_str(word)
- .unwrap_or_else(|| panic!("Word '{}' not found in dictionary", word))
+ .unwrap_or_else(|| panic!("Word '{word}' not found in dictionary"))
.clone()
}
diff --git a/harper-core/tests/linters.rs b/harper-core/tests/linters.rs
index 494f60067..19090209f 100644
--- a/harper-core/tests/linters.rs
+++ b/harper-core/tests/linters.rs
@@ -225,7 +225,7 @@ fn test_most_lints() {
if !lint.suggestions.is_empty() {
out.push_str("Suggest:\n");
for suggestion in &lint.suggestions {
- out.push_str(&format!(" - {}\n", suggestion));
+ out.push_str(&format!(" - {suggestion}\n"));
}
}
diff --git a/harper-core/tests/pos_tags.rs b/harper-core/tests/pos_tags.rs
index 110e0811f..6a381cb3d 100644
--- a/harper-core/tests/pos_tags.rs
+++ b/harper-core/tests/pos_tags.rs
@@ -107,10 +107,8 @@ fn format_word_tag(word: &WordMetadata) -> String {
_ => {}
}
// Treat unmarked (neither singular nor plural) common nouns as singular
- if noun.is_singular.is_none() && noun.is_plural.is_none() {
- if noun.is_proper.is_none() {
- tag.push_str("Sg");
- }
+ if noun.is_singular.is_none() && noun.is_plural.is_none() && noun.is_proper.is_none() {
+ tag.push_str("Sg");
}
add_bool(&mut tag, "$", noun.is_possessive);
add(&tag, &mut tags);
diff --git a/harper-core/tests/snapshot.rs b/harper-core/tests/snapshot.rs
index 2ad6178ac..9d9b356de 100644
--- a/harper-core/tests/snapshot.rs
+++ b/harper-core/tests/snapshot.rs
@@ -85,6 +85,6 @@ pub fn snapshot_all_text_files(
.sum();
if errors > 0 {
- panic!("{} errors occurred while processing files", errors);
+ panic!("{errors} errors occurred while processing files");
}
}
diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs
index cac21c896..78db8f120 100644
--- a/harper-ls/src/backend.rs
+++ b/harper-ls/src/backend.rs
@@ -207,7 +207,7 @@ impl Backend {
.ok_or_else(|| anyhow!("Unable to convert URL to file path."))?,
)
.await
- .with_context(|| format!("Unable to read from file {:?}", uri))?;
+ .with_context(|| format!("Unable to read from file {uri:?}"))?;
self.update_document(uri, &content, language_id).await
}
@@ -656,7 +656,7 @@ impl LanguageServer for Backend {
}
"HarperOpen" => match open::that(&first) {
Ok(()) => {
- let message = format!(r#"Opened "{}""#, first);
+ let message = format!(r#"Opened "{first}""#);
self.client.log_message(MessageType::INFO, &message).await;
diff --git a/harper-ls/src/diagnostics.rs b/harper-ls/src/diagnostics.rs
index 08639829f..1aa0cff8a 100644
--- a/harper-ls/src/diagnostics.rs
+++ b/harper-ls/src/diagnostics.rs
@@ -91,13 +91,13 @@ pub fn lint_to_code_actions<'a>(
let orig = lint.span.get_content_string(source);
results.push(CodeActionOrCommand::Command(Command::new(
- format!("Add \"{}\" to the global dictionary.", orig),
+ format!("Add \"{orig}\" to the global dictionary."),
"HarperAddToUserDict".to_string(),
Some(vec![orig.clone().into(), uri.to_string().into()]),
)));
results.push(CodeActionOrCommand::Command(Command::new(
- format!("Add \"{}\" to the file dictionary.", orig),
+ format!("Add \"{orig}\" to the file dictionary."),
"HarperAddToFileDict".to_string(),
Some(vec![orig.into(), uri.to_string().into()]),
)));
diff --git a/harper-ls/src/main.rs b/harper-ls/src/main.rs
index f3d039090..4484be068 100644
--- a/harper-ls/src/main.rs
+++ b/harper-ls/src/main.rs
@@ -64,7 +64,7 @@ async fn main() -> anyhow::Result<()> {
Server::new(stdin, stdout, socket).serve(service).await;
} else {
let listener = TcpListener::bind(DEFAULT_ADDRESS).await.unwrap();
- println!("Listening on {}", DEFAULT_ADDRESS);
+ println!("Listening on {DEFAULT_ADDRESS}");
let (stream, _) = listener.accept().await.unwrap();
let (read, write) = tokio::io::split(stream);
Server::new(read, write, socket).serve(service).await;
diff --git a/harper-pos-utils/src/chunker/brill_chunker/mod.rs b/harper-pos-utils/src/chunker/brill_chunker/mod.rs
index f12d0bd00..c2046cd22 100644
--- a/harper-pos-utils/src/chunker/brill_chunker/mod.rs
+++ b/harper-pos-utils/src/chunker/brill_chunker/mod.rs
@@ -172,8 +172,8 @@ impl BrillChunker {
}
println!("=============");
- println!("Total tokens in training set: {}", total_tokens);
- println!("Tokens incorrectly flagged: {}", error_counter);
+ println!("Total tokens in training set: {total_tokens}");
+ println!("Tokens incorrectly flagged: {error_counter}");
println!(
"Error rate: {}%",
error_counter as f32 / total_tokens as f32 * 100.
diff --git a/harper-pos-utils/src/tagger/brill_tagger/mod.rs b/harper-pos-utils/src/tagger/brill_tagger/mod.rs
index 8e8693a74..b05c4ccb4 100644
--- a/harper-pos-utils/src/tagger/brill_tagger/mod.rs
+++ b/harper-pos-utils/src/tagger/brill_tagger/mod.rs
@@ -171,7 +171,7 @@ impl BrillTagger<FreqDict> {
}
println!("=============");
- println!("Total tokens in training set: {}", total_tokens);
+ println!("Total tokens in training set: {total_tokens}");
println!(
"Tokens incorrectly tagged: {}",
error_counter.total_errors()
diff --git a/justfile b/justfile
index 22fedb26c..5a408c324 100644
--- a/justfile
+++ b/justfile
@@ -420,9 +420,12 @@ registerlinter module name:
# Print affixes and their descriptions from affixes.json
printaffixes:
#! /usr/bin/env node
- Object.entries(
- require('{{justfile_directory()}}/harper-core/affixes.json').affixes
- ).forEach(([affix, fields]) => {
+ const affixesData = require('{{justfile_directory()}}/harper-core/affixes.json');
+ const allAffixes = {
+ ...affixesData.affixes || {},
+ ...affixesData.properties || {}
+ };
+ Object.entries(allAffixes).sort((a, b) => a[0].localeCompare(b[0])).forEach(([affix, fields]) => {
const description = fields['#'] || '';
description && console.log(affix + ': ' + description);
});