Skip to content

Commit

Permalink
style: add semicolon at the end of expressions used as statements
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Oct 2, 2024
1 parent be22a53 commit 8f59473
Show file tree
Hide file tree
Showing 35 changed files with 50 additions and 49 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ testutils = { path = "lib/testutils" }

[workspace.lints.clippy]
explicit_iter_loop = "deny"
semicolon_if_nothing_returned = "deny"
uninlined_format_args = "deny"

# Insta suggests compiling these packages in opt mode for faster testing.
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl TracingSubscription {
.modify(|filter| {
*filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive(tracing::metadata::LevelFilter::DEBUG.into())
.from_env_lossy()
.from_env_lossy();
})
.map_err(|err| internal_error_with_message("failed to enable debug logging", err))?;
tracing::info!("debug logging enabled");
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/config/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn check_wc_author(
AuthorChange::Email => &author.email,
};
if new_value.as_str() != Some(orig_value) {
warn_wc_author(ui, &author.name, &author.email)?
warn_wc_author(ui, &author.name, &author.email)?;
}
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(crate) fn cmd_init(
ui.warning_default(),
"`--git` and `--git-repo` are deprecated.
Use `jj git init` instead"
)?
)?;
} else {
if !command.settings().allow_native_backend() {
return Err(user_error_with_hint(
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/operation/abandon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn cmd_op_abandon(
let mut locked_ws = workspace.start_working_copy_mutation()?;
let old_op_id = locked_ws.locked_wc().old_operation_id();
if let Some((_, new_id)) = reparented_head_ops().find(|(old, _)| old.id() == old_op_id) {
locked_ws.finish(new_id.clone())?
locked_ws.finish(new_id.clone())?;
} else {
writeln!(
ui.warning_default(),
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub(crate) fn cmd_status(
formatter.labeled("conflict"),
"There are unresolved conflicts at these paths:"
)?;
print_conflicted_paths(&conflicts, formatter, &workspace_command)?
print_conflicted_paths(&conflicts, formatter, &workspace_command)?;
}

let template = workspace_command.commit_summary_template();
Expand Down
4 changes: 2 additions & 2 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ pub fn default_config() -> config::Config {
.add_source(from_toml!("config/revsets.toml"))
.add_source(from_toml!("config/templates.toml"));
if cfg!(unix) {
builder = builder.add_source(from_toml!("config/unix.toml"))
builder = builder.add_source(from_toml!("config/unix.toml"));
}
if cfg!(windows) {
builder = builder.add_source(from_toml!("config/windows.toml"))
builder = builder.add_source(from_toml!("config/windows.toml"));
}
builder.build().unwrap()
}
Expand Down
4 changes: 2 additions & 2 deletions cli/src/diff_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ fn show_diff_line_tokens(
match token_type {
DiffTokenType::Matching => formatter.write_all(content)?,
DiffTokenType::Different => {
formatter.with_label("token", |formatter| formatter.write_all(content))?
formatter.with_label("token", |formatter| formatter.write_all(content))?;
}
}
}
Expand Down Expand Up @@ -1402,7 +1402,7 @@ pub fn show_diff_summary(
CopyOperation::Rename => ("renamed", "R"),
};
let path = path_converter.format_copied_path(before_path, after_path);
writeln!(formatter.labeled(label), "{sigil} {path}")?
writeln!(formatter.labeled(label), "{sigil} {path}")?;
} else {
let path = path_converter.format_file_path(after_path);
match (before.is_present(), after.is_present()) {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl<W: Write> Formatter for ColorFormatter<W> {
fn pop_label(&mut self) -> io::Result<()> {
self.labels.pop();
if self.labels.is_empty() {
self.write_new_style()?
self.write_new_style()?;
}
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions cli/src/merge_tools/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ fn make_diff_sections(
.split_inclusive('\n')
.map(|line| Cow::Owned(line.to_owned()))
.collect(),
})
});
}
DiffHunk::Different(sides) => {
assert_eq!(sides.len(), 2, "only two inputs were provided to the diff");
Expand All @@ -285,7 +285,7 @@ fn make_diff_sections(
make_section_changed_lines(right_side, scm_record::ChangeType::Added),
]
.concat(),
})
});
}
}
}
Expand Down Expand Up @@ -361,7 +361,7 @@ pub fn make_diff_files(
is_checked: false,
old_description: None,
new_description: Some(Cow::Owned(describe_binary(hash.as_deref(), num_bytes))),
})
});
}

(
Expand Down Expand Up @@ -426,7 +426,7 @@ pub fn make_diff_files(
is_checked: false,
old_description: Some(Cow::Owned(describe_binary(hash.as_deref(), num_bytes))),
new_description: None,
})
});
}
}

Expand Down Expand Up @@ -507,7 +507,7 @@ pub fn apply_diff_builtin(
executable: file.get_file_mode()
== Some(scm_record::FileMode(mode::EXECUTABLE)),
}),
)
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/movement_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Direction {
write!(formatter, "Working copy parent: ")?;
}
template.format(commit, formatter)
})
});
});

cmd_err
Expand Down
2 changes: 1 addition & 1 deletion cli/src/templater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub struct ConcatTemplate<T>(pub Vec<T>);
impl<T: Template> Template for ConcatTemplate<T> {
fn format(&self, formatter: &mut TemplateFormatter) -> io::Result<()> {
for template in &self.0 {
template.format(formatter)?
template.format(formatter)?;
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_git_colocated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ fn test_git_colocated_external_checkout() {
let git_check_out_ref = |name| {
git_repo
.set_head_detached(git_repo.find_reference(name).unwrap().target().unwrap())
.unwrap()
.unwrap();
};

test_env.jj_cmd_ok(&repo_path, &["git", "init", "--git-repo=."]);
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_log_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ fn test_log_null_terminate_multiline_descriptions() {
insta::assert_debug_snapshot!(
stdout,
@r###""commit 3 line 1\n\ncommit 3 line 2\n\0commit 2 line 1\n\ncommit 2 line 2\n\0commit 1 line 1\n\ncommit 1 line 2\n\0""###
)
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_next_prev_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ fn test_prev_prompts_on_multiple_parents() {
Hint: Working copy parent: mzvwutvl bc4f4fe3 (empty) third
Hint: Working copy parent: kkmpptxz b0d21db3 (empty) second
Hint: Working copy parent: qpvuntsm fa15625b (empty) first
"###)
"###);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_parallelize_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ fn test_parallelize_complex_nonlinear_target() {
│ ○ 14ca4df576b3 4 parents:
├─╯
◆ 000000000000 parents:
"###)
"###);
}

fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_util_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn test_util_config_schema() {
[...]
}
}
"###)
"###);
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/benches/diff_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int main(int argc, char **argv)
}
"##,
])
})
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl PartialOrd for Commit {

impl Hash for Commit {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id.hash(state)
self.id.hash(state);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/content_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<T: ContentHash> ContentHash for [T] {

impl<T: ContentHash> ContentHash for Vec<T> {
fn hash(&self, state: &mut impl DigestUpdate) {
self.as_slice().hash(state)
self.as_slice().hash(state);
}
}

Expand All @@ -97,7 +97,7 @@ impl<T: ContentHash> ContentHash for Option<T> {
None => state.update(&0u32.to_le_bytes()),
Some(x) => {
state.update(&1u32.to_le_bytes());
x.hash(state)
x.hash(state);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/default_index/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Eq for IndexEntry<'_> {}

impl Hash for IndexEntry<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.pos.hash(state)
self.pos.hash(state);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/default_index/revset_graph_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<'a> RevsetGraphWalk<'a> {
parent_edges
.iter()
.filter(|edge| known_ancestors.insert(edge.target)),
)
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/default_index/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl DefaultIndexStore {
change_id_length,
)?;
maybe_parent_file = Some(parent_file.clone());
mutable_index = DefaultMutableIndex::incremental(parent_file)
mutable_index = DefaultMutableIndex::incremental(parent_file);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ mod tests {

#[test]
fn test_find_word_ranges_multibyte() {
assert_eq!(find_word_ranges("⊢".as_bytes()), vec![0..3])
assert_eq!(find_word_ranges("⊢".as_bytes()), vec![0..3]);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/fileset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ fn build_union_matcher(expressions: &[FilesetExpression]) -> Box<dyn Matcher> {
FilePattern::FilePath(path) => file_paths.push(path),
FilePattern::PrefixPath(path) => prefix_paths.push(path),
FilePattern::FileGlob { dir, pattern } => {
file_globs.push((dir, pattern.clone()))
file_globs.push((dir, pattern.clone()));
}
}
continue;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,10 +1782,10 @@ pub fn parse_gitmodules(
// TODO Git warns when a duplicate config entry is found, we should
// consider doing the same.
("path", PartialSubmoduleConfig { path: None, .. }) => {
map_entry.path = Some(config_value.to_string())
map_entry.path = Some(config_value.to_string());
}
("url", PartialSubmoduleConfig { url: None, .. }) => {
map_entry.url = Some(config_value.to_string())
map_entry.url = Some(config_value.to_string());
}
_ => (),
};
Expand Down
2 changes: 1 addition & 1 deletion lib/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
reverse_edges.entry(target).or_default().push(GraphEdge {
target: node.clone(),
edge_type,
})
});
}
entries.push(node);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/local_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,10 @@ fn conflict_to_proto(conflict: &Conflict) -> crate::protos::local_store::Conflic
fn conflict_from_proto(proto: crate::protos::local_store::Conflict) -> Conflict {
let mut conflict = Conflict::default();
for term in proto.removes {
conflict.removes.push(conflict_term_from_proto(term))
conflict.removes.push(conflict_term_from_proto(term));
}
for term in proto.adds {
conflict.adds.push(conflict_term_from_proto(term))
conflict.adds.push(conflict_term_from_proto(term));
}
conflict
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl<T> FromIterator<T> for MergeBuilder<T> {

impl<T> Extend<T> for MergeBuilder<T> {
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
self.values.extend(iter)
self.values.extend(iter);
}
}

Expand Down Expand Up @@ -512,7 +512,7 @@ impl<T> Merge<Merge<T>> {

impl<T: ContentHash> ContentHash for Merge<T> {
fn hash(&self, state: &mut impl DigestUpdate) {
self.values.hash(state)
self.values.hash(state);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl PartialOrd for Operation {

impl Hash for Operation {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id.hash(state)
self.id.hash(state);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/simple_op_heads_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl OpHeadsStore for SimpleOpHeadsStore {
assert!(!old_ids.contains(new_id));
self.add_op_head(new_id);
for old_id in old_ids {
self.remove_op_head(old_id)
self.remove_op_head(old_id);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/tests/test_bad_locking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn copy_directory(src: &Path, dst: &Path) {
let base_name = child_src.file_name().unwrap();
let child_dst = dst.join(base_name);
if child_src.is_dir() {
copy_directory(&child_src, &child_dst)
copy_directory(&child_src, &child_dst);
} else {
std::fs::copy(&child_src, &child_dst).unwrap();
}
Expand Down
Loading

0 comments on commit 8f59473

Please sign in to comment.