Skip to content
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

Fix clippy issues. #357

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions crates/weaver_forge/src/extensions/case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ mod tests {
add_filters(&mut env);

assert_eq!(
env.render_str("{{ 'Hello World' | kebab_case }}", &ctx)
env.render_str("{{ 'Hello World' | kebab_case }}", ctx)
.unwrap(),
"hello-world"
);
Expand All @@ -132,7 +132,7 @@ mod tests {
add_filters(&mut env);

assert_eq!(
env.render_str("{{ 'Hello World' | lower_case }}", &ctx)
env.render_str("{{ 'Hello World' | lower_case }}", ctx)
.unwrap(),
"hello world"
);
Expand Down Expand Up @@ -190,7 +190,7 @@ mod tests {
add_filters(&mut env);

assert_eq!(
env.render_str("{{ 'Hello World' | title_case }}", &ctx)
env.render_str("{{ 'Hello World' | title_case }}", ctx)
.unwrap(),
"Hello World"
);
Expand Down
6 changes: 3 additions & 3 deletions crates/weaver_forge/src/extensions/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub(crate) fn comment_with_prefix(input: &Value, prefix: &str) -> String {
}

/// Generic comment filter reading its configuration from the `weaver.yaml` file.
#[allow(clippy::assigning_clones)]
pub(crate) fn comment(
config: &WeaverConfig,
) -> Result<impl Fn(&Value, Kwargs) -> Result<String, minijinja::Error>, Error> {
Expand Down Expand Up @@ -98,7 +99,6 @@ pub(crate) fn comment(
} else {
input.to_string()
};

if comment_format.trim {
comment = comment.trim().to_owned();
}
Expand Down Expand Up @@ -349,7 +349,7 @@ it's RECOMMENDED to:
// Test with an undefined field in the context
let ctx = serde_json::json!({});
let observed_comment = env
.render_str("{{ note | comment(format='java', indent=2) }}", &ctx)
.render_str("{{ note | comment(format='java', indent=2) }}", ctx)
.unwrap();
assert_eq!(observed_comment, "");

Expand All @@ -361,7 +361,7 @@ it's RECOMMENDED to:
let observed_comment = env
.render_str(
"{{ [brief,'Note: ', note, something_not_in_ctx] | comment(indent=2) }}",
&ctx,
ctx,
)
.unwrap();
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions crates/weaver_forge/src/formats/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'source> HtmlRenderer<'source> {
code: code.to_owned(),
};
self.env
.render_str(&options.inline_code_snippet, &ctx)
.render_str(&options.inline_code_snippet, ctx)
.map_err(|e| InvalidCodeSnippet {
format: format.to_owned(),
mode: INLINE_CODE_SNIPPET_MODE.to_owned(),
Expand All @@ -170,7 +170,7 @@ impl<'source> HtmlRenderer<'source> {
code: code.to_owned(),
};
self.env
.render_str(&options.block_code_snippet, &ctx)
.render_str(&options.block_code_snippet, ctx)
.map_err(|e| InvalidCodeSnippet {
format: format.to_owned(),
mode: BLOCK_CODE_SNIPPET_MODE.to_owned(),
Expand Down
6 changes: 3 additions & 3 deletions crates/weaver_forge/src/formats/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl RenderContext {

/// Set the line prefix to add in front of each new line.
fn set_line_prefix(&mut self, prefix: &str) {
self.line_prefix = prefix.to_owned();
prefix.clone_into(&mut self.line_prefix);
}

/// Skip the line prefix on the first line.
Expand All @@ -94,7 +94,7 @@ impl RenderContext {

/// Reset the line prefix.
fn reset_line_prefix(&mut self) {
self.line_prefix = "".to_owned();
"".clone_into(&mut self.line_prefix);
self.skip_line_prefix_on_first_line = false;
}

Expand Down Expand Up @@ -197,7 +197,7 @@ impl MarkdownRenderer {
}
Node::Text(text) => {
if options.escape_backslashes {
ctx.add_text(&text.value.replace("\\", "\\\\"));
ctx.add_text(&text.value.replace('\\', "\\\\"));
} else {
ctx.add_text(&text.value);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/weaver_forge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ mod tests {

// Delete all the files in the observed_output/target directory
// before generating the new files.
fs::remove_dir_all(&format!("observed_output/{}", target)).unwrap_or_default();
fs::remove_dir_all(format!("observed_output/{}", target)).unwrap_or_default();

(
TestLogger::default(),
Expand Down
Loading