Skip to content

Commit 6c55064

Browse files
authored
Update Rust toolchain to 1.92.0 and fix clippy (#23)
* Update Rust toolchain to 1.92.0 Fix new clippy lints * Update assert_cmd and fix deprecation warnings
1 parent 6161fe5 commit 6c55064

25 files changed

Lines changed: 98 additions & 112 deletions

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fnmatch-regex2 = "0.3.0"
5050
strip-ansi-escapes = "0.2.0"
5151

5252
[dev-dependencies]
53-
assert_cmd = "2.0.10" # testing CLI
53+
assert_cmd = "2.1.1" # testing CLI
5454
rusty-hook = "^0.11.2" # git hooks
5555
predicates = "3.0.2" # kind of like rspec assertions
5656
pretty_assertions = "1.3.0" # Shows a more readable diff when comparing objects

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.83.0"
2+
channel = "1.92.0"
33
components = ["clippy", "rustfmt"]
44
targets = ["x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu"]

src/packs/checker.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,7 @@ mod tests {
517517
#[test]
518518
fn test_write_violations() {
519519
let chec_result = CheckAllResult {
520-
reportable_violations: vec![
521-
Violation {
520+
reportable_violations: [Violation {
522521
message: "foo/bar/file1.rb:10:5\nPrivacy violation: `::Foo::PrivateClass` is private to `foo`, but referenced from `bar`".to_string(),
523522
identifier: ViolationIdentifier {
524523
violation_type: "Privacy".to_string(),
@@ -539,8 +538,7 @@ mod tests {
539538
referencing_pack_name: "foo".to_string(),
540539
defining_pack_name: "bar".to_string(),
541540
}
542-
}
543-
].iter().cloned().collect(),
541+
}].iter().cloned().collect(),
544542
stale_violations: Vec::new(),
545543
strict_mode_violations: HashSet::new(),
546544
};

src/packs/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Configuration {
8686

8787
pub(crate) fn constant_resolver_configuration(
8888
&self,
89-
) -> ConstantResolverConfiguration {
89+
) -> ConstantResolverConfiguration<'_> {
9090
ConstantResolverConfiguration {
9191
absolute_root: &self.absolute_root,
9292
cache_directory: &self.cache_directory,

src/packs/creator.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ pub fn create(
3535
)?;
3636

3737
write_pack_to_disk(&new_pack)?;
38-
let pack_name =
39-
&name.split('/').last().context("unable to find pack name")?;
38+
let pack_name = &name
39+
.split('/')
40+
.next_back()
41+
.context("unable to find pack name")?;
4042
std::fs::create_dir_all(new_pack_path.join("app/public/").join(pack_name))
4143
.context(format!("failed to create app/public/{}", &name))?;
4244
std::fs::create_dir_all(

src/packs/file_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ pub fn get_file_type(path: &Path) -> Option<SupportedFileType> {
2727

2828
let is_ruby_file = ruby_extensions
2929
.into_iter()
30-
.any(|ext| extension.map_or(false, |e| e == ext))
30+
.any(|ext| extension.is_some_and(|e| e == ext))
3131
|| ruby_special_files.iter().any(|file| path.ends_with(file));
3232

33-
let is_erb_file = path.extension().map_or(false, |ext| ext == "erb");
33+
let is_erb_file = path.extension().is_some_and(|ext| ext == "erb");
3434

3535
if is_ruby_file {
3636
Some(SupportedFileType::Ruby)

src/packs/parsing/ruby/parse_utils.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ pub fn get_reference_from_active_record_association(
116116
.chain(ASSOCIATION_METHOD_NAMES.iter().copied().map(String::from))
117117
.collect();
118118

119-
let is_association = combined_associations
120-
.iter()
121-
.any(|association_method| node.method_name == *association_method);
119+
let is_association = combined_associations.contains(&node.method_name);
122120

123121
if is_association {
124122
let first_arg: Option<&Node> = node.args.first();

src/packs/parsing/ruby/rails_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub(crate) fn get_acronyms_from_disk(
1616
let inflections_file =
1717
std::fs::read_to_string(inflections_path).unwrap();
1818
let inflections_lines = inflections_file.lines();
19+
let re = Regex::new(r#"['\\"]"#).unwrap();
1920
for line in inflections_lines {
2021
if line.contains(".acronym") {
21-
let re = Regex::new(r#"['\\"]"#).unwrap();
2222
let acronym = re.split(line).nth(1).unwrap();
2323
acronyms.insert(acronym.to_string());
2424
}

tests/add_constant_dependencies.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use assert_cmd::Command;
1+
use assert_cmd::cargo::cargo_bin_cmd;
22
use predicates::prelude::*;
33
use pretty_assertions::assert_eq;
44
use serial_test::serial;
@@ -9,7 +9,7 @@ mod common;
99
#[test]
1010
#[serial]
1111
fn test_add_constant_dependencies() -> anyhow::Result<()> {
12-
Command::cargo_bin("pks")?
12+
cargo_bin_cmd!("pks")
1313
.arg("--project-root")
1414
.arg("tests/fixtures/app_with_missing_dependencies")
1515
.arg("update-dependencies-for-constant")
@@ -43,7 +43,7 @@ fn test_add_constant_dependencies() -> anyhow::Result<()> {
4343
#[test]
4444
#[serial]
4545
fn test_add_constant_dependencies_no_dependencies() -> anyhow::Result<()> {
46-
Command::cargo_bin("pks")?
46+
cargo_bin_cmd!("pks")
4747
.arg("--project-root")
4848
.arg("tests/fixtures/app_with_missing_dependencies")
4949
.arg("update-dependencies-for-constant")

tests/add_dependency_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use assert_cmd::Command;
1+
use assert_cmd::cargo::cargo_bin_cmd;
22
use predicates::prelude::*;
33
use pretty_assertions::assert_eq;
44
use serial_test::serial;
@@ -9,7 +9,7 @@ mod common;
99
#[test]
1010
#[serial]
1111
fn test_add_dependency() -> Result<(), Box<dyn Error>> {
12-
Command::cargo_bin("pks")?
12+
cargo_bin_cmd!("pks")
1313
.arg("--project-root")
1414
.arg("tests/fixtures/app_with_missing_dependency")
1515
.arg("add-dependency")
@@ -41,7 +41,7 @@ fn test_add_dependency() -> Result<(), Box<dyn Error>> {
4141
#[test]
4242
#[serial]
4343
fn test_add_dependency_creating_cycle() -> Result<(), Box<dyn Error>> {
44-
Command::cargo_bin("pks")?
44+
cargo_bin_cmd!("pks")
4545
.arg("--project-root")
4646
.arg("tests/fixtures/app_with_missing_dependency")
4747
.arg("add-dependency")
@@ -80,7 +80,7 @@ fn test_add_dependency_creating_cycle() -> Result<(), Box<dyn Error>> {
8080

8181
#[test]
8282
fn test_add_dependency_unnecessarily() -> Result<(), Box<dyn Error>> {
83-
Command::cargo_bin("pks")?
83+
cargo_bin_cmd!("pks")
8484
.arg("--project-root")
8585
.arg("tests/fixtures/app_with_missing_dependency")
8686
.arg("add-dependency")

0 commit comments

Comments
 (0)