diff --git a/clippy.toml b/clippy.toml index 5616f26486..0d0ff26ced 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,3 +1 @@ cognitive-complexity-threshold = 1337 - -doc-valid-idents = ["FreeBSD"] diff --git a/justfile b/justfile index fc518e3c5f..d78ae7bbc9 100755 --- a/justfile +++ b/justfile @@ -48,15 +48,16 @@ man: view-man: man man man/just.1 -version := `sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1` - # add git log messages to changelog changes: git log --pretty=format:%s >> CHANGELOG.md -check: actionlint fmt clippy test forbid +check: fmt clippy test forbid + #!/usr/bin/env bash + set -euxo pipefail git diff --no-ext-diff --quiet --exit-code - grep '^\[{{ version }}\]' CHANGELOG.md + VERSION=`sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1` + grep "^\[$VERSION\]" CHANGELOG.md cargo +nightly generate-lockfile -Z minimal-versions cargo ltest git checkout Cargo.lock @@ -105,11 +106,7 @@ install-dev-deps: # install system development dependencies with homebrew install-dev-deps-homebrew: - brew tap "rhysd/actionlint" "https://github.com/rhysd/actionlint" - brew install actionlint help2man shellcheck - -actionlint: - SHELLCHECK_OPTS='-e SC2006 -e SC2002 -e SC2050' actionlint + brew install help2man # everyone's favorite animate paper clip clippy: diff --git a/src/function.rs b/src/function.rs index 5232814ede..0c044cffb3 100644 --- a/src/function.rs +++ b/src/function.rs @@ -1,3 +1,6 @@ +#![allow(clippy::unknown_clippy_lints)] +#![allow(clippy::unnecessary_wraps)] + use crate::common::*; use Function::*; diff --git a/src/justfile.rs b/src/justfile.rs index f9746ced57..eb0923ca9b 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -91,7 +91,7 @@ impl<'src> Justfile<'src> { } let dotenv = if config.load_dotenv { - load_dotenv(&config, &self.settings, &search.working_directory)? + load_dotenv(config, &self.settings, &search.working_directory)? } else { BTreeMap::new() }; @@ -129,7 +129,7 @@ impl<'src> Justfile<'src> { binary, arguments, .. } => { let mut command = if config.shell_command { - let mut command = self.settings.shell_command(&config); + let mut command = self.settings.shell_command(config); command.arg(binary); command } else { @@ -168,7 +168,7 @@ impl<'src> Justfile<'src> { print!("{}", value); } else { return Err(Error::EvalUnknownVariable { - suggestion: self.suggest_variable(&variable), + suggestion: self.suggest_variable(variable), variable: variable.clone(), }); } @@ -261,7 +261,7 @@ impl<'src> Justfile<'src> { let mut ran = BTreeSet::new(); for (recipe, arguments) in grouped { - self.run_recipe(&context, recipe, arguments, &dotenv, &search, &mut ran)?; + self.run_recipe(&context, recipe, arguments, &dotenv, search, &mut ran)?; } Ok(()) @@ -344,7 +344,7 @@ impl<'src> Justfile<'src> { } let mut invocation = vec![recipe.name().to_owned()]; - for argument in arguments.iter().cloned() { + for argument in arguments.iter().copied() { invocation.push(argument.to_owned()); } diff --git a/src/keyed.rs b/src/keyed.rs index edea597bd5..79405f7e1c 100644 --- a/src/keyed.rs +++ b/src/keyed.rs @@ -15,7 +15,7 @@ where S: Serializer, K: Keyed<'src>, { - serializer.serialize_str(&keyed.key()) + serializer.serialize_str(keyed.key()) } pub(crate) fn serialize_option<'src, S, K>( diff --git a/src/lexer.rs b/src/lexer.rs index 42267cf9cc..54be8658cd 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -174,7 +174,7 @@ impl<'src> Lexer<'src> { /// Get current indentation fn indentation(&self) -> &'src str { - self.indentation.last().cloned().unwrap() + self.indentation.last().unwrap() } /// Are we currently indented diff --git a/src/lib.rs b/src/lib.rs index c7d64ec83f..0a28641bf6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![deny(clippy::all, clippy::pedantic)] #![allow( + clippy::doc_markdown, clippy::enum_glob_use, clippy::if_not_else, clippy::missing_errors_doc, diff --git a/src/load_dotenv.rs b/src/load_dotenv.rs index 31187e7536..5e2fc1800b 100644 --- a/src/load_dotenv.rs +++ b/src/load_dotenv.rs @@ -15,7 +15,7 @@ pub(crate) fn load_dotenv( } if let Some(path) = &config.dotenv_path { - return load_from_file(config, settings, &path); + return load_from_file(config, settings, path); } let filename = config diff --git a/src/name.rs b/src/name.rs index e9b93ecc9c..e9093b95a0 100644 --- a/src/name.rs +++ b/src/name.rs @@ -56,6 +56,6 @@ impl<'src> Serialize for Name<'src> { where S: Serializer, { - serializer.serialize_str(&self.lexeme()) + serializer.serialize_str(self.lexeme()) } } diff --git a/src/node.rs b/src/node.rs index c3b0f9b040..270d6bb2b8 100644 --- a/src/node.rs +++ b/src/node.rs @@ -10,8 +10,8 @@ pub(crate) trait Node<'src> { impl<'src> Node<'src> for Ast<'src> { fn tree(&self) -> Tree<'src> { Tree::atom("justfile") - .extend(self.items.iter().map(|item| item.tree())) - .extend(self.warnings.iter().map(|warning| warning.tree())) + .extend(self.items.iter().map(Node::tree)) + .extend(self.warnings.iter().map(Node::tree)) } } @@ -179,7 +179,7 @@ impl<'src> Node<'src> for UnresolvedRecipe<'src> { } if !self.body.is_empty() { - t.push_mut(Tree::atom("body").extend(self.body.iter().map(|line| line.tree()))); + t.push_mut(Tree::atom("body").extend(self.body.iter().map(Node::tree))); } t @@ -200,7 +200,7 @@ impl<'src> Node<'src> for Parameter<'src> { impl<'src> Node<'src> for Line<'src> { fn tree(&self) -> Tree<'src> { - Tree::list(self.fragments.iter().map(|fragment| fragment.tree())) + Tree::list(self.fragments.iter().map(Node::tree)) } } diff --git a/src/parser.rs b/src/parser.rs index 7c50cda48e..996c07a4ca 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -60,7 +60,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { expected: self .expected .iter() - .cloned() + .copied() .filter(|kind| *kind != ByteOrderMark) .collect::>(), found: self.next()?.kind, @@ -77,7 +77,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { fn rest(&self) -> impl Iterator> + 'tokens { self.tokens[self.next..] .iter() - .cloned() + .copied() .filter(|token| token.kind != Whitespace) } @@ -654,10 +654,10 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { }; Ok(Parameter { - name, - kind, default, export, + kind, + name, }) } @@ -777,7 +777,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> { self.expect(BracketR)?; Ok(Set { - value: Setting::Shell(setting::Shell { command, arguments }), + value: Setting::Shell(setting::Shell { arguments, command }), name, }) } else { diff --git a/src/recipe_resolver.rs b/src/recipe_resolver.rs index 7e8a83ab6f..cc8ad7d2bf 100644 --- a/src/recipe_resolver.rs +++ b/src/recipe_resolver.rs @@ -87,7 +87,7 @@ impl<'src: 'run, 'run> RecipeResolver<'src, 'run> { if let Some(resolved) = self.resolved_recipes.get(name) { // dependency already resolved - dependencies.push(Rc::clone(&resolved)); + dependencies.push(Rc::clone(resolved)); } else if stack.contains(&name) { let first = stack[0]; stack.push(first); @@ -97,7 +97,7 @@ impl<'src: 'run, 'run> RecipeResolver<'src, 'run> { circle: stack .iter() .skip_while(|name| **name != dependency.recipe.lexeme()) - .cloned() + .copied() .collect(), }), ); diff --git a/src/scope.rs b/src/scope.rs index 08d82233f8..9f1913a086 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -46,7 +46,7 @@ impl<'src, 'run> Scope<'src, 'run> { } pub(crate) fn names(&self) -> impl Iterator { - self.bindings.keys().cloned() + self.bindings.keys().copied() } pub(crate) fn parent(&self) -> Option<&'run Scope<'src, 'run>> { diff --git a/src/search.rs b/src/search.rs index fc654bae8f..fc4aa946e7 100644 --- a/src/search.rs +++ b/src/search.rs @@ -18,7 +18,7 @@ impl Search { ) -> SearchResult { match search_config { SearchConfig::FromInvocationDirectory => { - let justfile = Self::justfile(&invocation_directory)?; + let justfile = Self::justfile(invocation_directory)?; let working_directory = Self::working_directory_from_justfile(&justfile)?; @@ -68,7 +68,7 @@ impl Search { ) -> SearchResult { match search_config { SearchConfig::FromInvocationDirectory => { - let working_directory = Self::project_root(&invocation_directory)?; + let working_directory = Self::project_root(invocation_directory)?; let justfile = working_directory.join(DEFAULT_JUSTFILE_NAME); @@ -174,7 +174,7 @@ impl Search { io_error, directory: directory.to_owned(), })?; - for project_root_child in PROJECT_ROOT_CHILDREN.iter().cloned() { + for project_root_child in PROJECT_ROOT_CHILDREN.iter().copied() { if entry.file_name() == project_root_child { return Ok(directory.to_owned()); } diff --git a/src/subcommand.rs b/src/subcommand.rs index b278db7a5d..e674486043 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -46,7 +46,7 @@ impl Subcommand { Self::changelog(); return Ok(()); } - Completions { shell } => return Self::completions(&shell), + Completions { shell } => return Self::completions(shell), Init => return Self::init(config), _ => {} } @@ -59,7 +59,7 @@ impl Subcommand { let src = loader.load(&search.justfile)?; - let tokens = Lexer::lex(&src)?; + let tokens = Lexer::lex(src)?; let ast = Parser::parse(&tokens)?; let justfile = Analyzer::analyze(ast.clone())?; @@ -74,16 +74,16 @@ impl Subcommand { Self::choose(config, justfile, &search, overrides, chooser.as_deref())?; } Command { overrides, .. } | Evaluate { overrides, .. } => { - justfile.run(config, &search, overrides, &[])? + justfile.run(config, &search, overrides, &[])?; } Dump => Self::dump(config, ast, justfile)?, - Format => Self::format(config, &search, &src, ast)?, + Format => Self::format(config, &search, src, ast)?, List => Self::list(config, justfile), Run { arguments, overrides, } => justfile.run(config, &search, overrides, arguments)?, - Show { ref name } => Self::show(config, &name, justfile)?, + Show { ref name } => Self::show(config, name, justfile)?, Summary => Self::summary(config, justfile), Variables => Self::variables(justfile), Changelog | Completions { .. } | Edit | Init => unreachable!(), @@ -107,7 +107,7 @@ impl Subcommand { .public_recipes(config.unsorted) .iter() .filter(|recipe| recipe.min_arguments() == 0) - .cloned() + .copied() .collect::>>(); if recipes.is_empty() { @@ -121,7 +121,7 @@ impl Subcommand { let result = justfile .settings - .shell_command(&config) + .shell_command(config) .arg(&chooser) .current_dir(&search.working_directory) .stdin(Stdio::piped()) @@ -132,8 +132,8 @@ impl Subcommand { Ok(child) => child, Err(io_error) => { return Err(Error::ChooserInvoke { - shell_binary: justfile.settings.shell_binary(&config).to_owned(), - shell_arguments: justfile.settings.shell_arguments(&config).join(" "), + shell_binary: justfile.settings.shell_binary(config).to_owned(), + shell_arguments: justfile.settings.shell_arguments(config).join(" "), chooser, io_error, }); @@ -365,7 +365,7 @@ impl Subcommand { } } - let max_line_width = cmp::min(line_widths.values().cloned().max().unwrap_or(0), 30); + let max_line_width = cmp::min(line_widths.values().copied().max().unwrap_or(0), 30); let doc_color = config.color.stdout().doc(); print!("{}", config.list_heading); @@ -392,7 +392,7 @@ impl Subcommand { doc_color.paint("#"), doc_color.paint(doc), padding = max_line_width - .saturating_sub(line_widths.get(name).cloned().unwrap_or(max_line_width)) + .saturating_sub(line_widths.get(name).copied().unwrap_or(max_line_width)) ); }; diff --git a/src/summary.rs b/src/summary.rs index a53054b426..52c5023000 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -87,11 +87,7 @@ impl Recipe { private: recipe.private, shebang: recipe.shebang, quiet: recipe.quiet, - dependencies: recipe - .dependencies - .iter() - .map(|dependency| Dependency::new(dependency)) - .collect(), + dependencies: recipe.dependencies.iter().map(Dependency::new).collect(), lines: recipe.body.iter().map(Line::new).collect(), parameters: recipe.parameters.iter().map(Parameter::new).collect(), aliases, diff --git a/src/table.rs b/src/table.rs index 06e8dc9fab..dfc2eace40 100644 --- a/src/table.rs +++ b/src/table.rs @@ -89,7 +89,6 @@ impl<'table, V: Keyed<'table> + 'table> IntoIterator for &'table Table<'table, V type IntoIter = btree_map::Iter<'table, &'table str, V>; type Item = (&'table &'table str, &'table V); - #[must_use] fn into_iter(self) -> btree_map::Iter<'table, &'table str, V> { self.map.iter() } diff --git a/src/unindent.rs b/src/unindent.rs index e1c0f87ab5..4dcc5664e1 100644 --- a/src/unindent.rs +++ b/src/unindent.rs @@ -14,7 +14,7 @@ pub fn unindent(text: &str) -> String { let common_indentation = lines .iter() .filter(|line| !blank(line)) - .cloned() + .copied() .map(indentation) .fold( None, diff --git a/tests/test.rs b/tests/test.rs index 8f8d31e0b9..bee962d8cb 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -146,7 +146,7 @@ impl Test { pub(crate) fn tree(self, mut tree: Tree) -> Self { tree.map(|_name, content| unindent(content)); - tree.instantiate(&self.tempdir.path()).unwrap(); + tree.instantiate(self.tempdir.path()).unwrap(); self }