Skip to content

Commit 7378f8c

Browse files
authored
Merge pull request #1 from rodneylab/style__linting
style linting
2 parents 03a0c9a + d23142d commit 7378f8c

File tree

8 files changed

+80
-72
lines changed

8 files changed

+80
-72
lines changed

.github/workflows/general.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
runs-on: ubuntu-latest
7272
strategy:
7373
matrix:
74-
msrv: ["1.74.0"]
74+
msrv: ["1.75.0"]
7575
name: ubuntu / ${{ matrix.msrv }}
7676
steps:
7777
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -81,6 +81,8 @@ jobs:
8181
uses: dtolnay/rust-toolchain@4f647fc679bcd3b11499ccb42104547c83dabe96 # stable
8282
with:
8383
toolchain: ${{ matrix.msrv }}
84+
- name: generate lockfile
85+
run: cargo generate-lockfile
8486
- name: cargo +${{ matrix.msrv }} check
8587
run: cargo check
8688
coverage:

.lycheeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/example/example-repo

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ authors = ["Rodney Johnson <[email protected]>"]
55
edition = "2021"
66
license = "BSD-3-Clause"
77
repository = "https://github.com/rodneylab/rust-crate-diffs"
8-
# clap 4.5.0 raises MSRV to 1.74
9-
rust-version = "1.74"
8+
# config 0.15.4 raises MSRV to 1.75
9+
rust-version = "1.75"
1010
description = "Check Cargo.toml dependency changes against git repo head"
1111

1212
# Faster snapshot runs

src/domain/cargo_toml/mod.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ use serde::Deserialize;
1414
use super::SemverVersion;
1515

1616
#[derive(Debug)]
17-
pub struct CargoTomlFile {
17+
pub struct File {
1818
dependencies: BTreeMap<String, CargoDependencyValue>,
1919
build_dependencies: Option<BTreeMap<String, CargoDependencyValue>>,
2020
dev_dependencies: Option<BTreeMap<String, CargoDependencyValue>>,
2121
}
2222

23-
impl CargoTomlFile {
23+
impl File {
2424
pub fn new(path: &str) -> anyhow::Result<Self> {
2525
let current_cargo = Config::builder()
2626
.add_source(config::File::with_name(path))
@@ -292,28 +292,33 @@ Ok(value) => value,
292292
#[derive(Debug, Deserialize, PartialEq)]
293293
#[cfg_attr(test, derive(serde::Serialize))]
294294
pub struct DetailedCargoDependency {
295-
#[allow(dead_code, reason = "Field needed for deserialisation")]
295+
// #[allow(dead_code, reason = "Field needed for deserialisation")]
296+
#[allow(dead_code)]
296297
version: String,
297298
}
298299

299300
#[derive(Debug, Deserialize, PartialEq)]
300301
#[cfg_attr(test, derive(serde::Serialize))]
301302
pub struct GitCargoDependency {
302-
#[allow(dead_code, reason = "Field needed for deserialisation")]
303+
// #[allow(dead_code, reason = "Field needed for deserialisation")]
304+
#[allow(dead_code)]
303305
git: String,
304306
}
305307

306308
#[derive(Debug, Deserialize, PartialEq)]
307309
#[cfg_attr(test, derive(serde::Serialize))]
308310
#[serde(untagged)]
309311
pub enum CargoDependencyValue {
310-
#[allow(dead_code, reason = "Field needed for deserialisation")]
312+
// #[allow(dead_code, reason = "Field needed for deserialisation")]
313+
#[allow(dead_code)]
311314
Simple(String),
312315

313-
#[allow(dead_code, reason = "Field needed for deserialisation")]
316+
// #[allow(dead_code, reason = "Field needed for deserialisation")]
317+
#[allow(dead_code)]
314318
Detailed(DetailedCargoDependency),
315319

316-
#[allow(dead_code, reason = "Field needed for deserialisation")]
320+
// #[allow(dead_code, reason = "Field needed for deserialisation")]
321+
#[allow(dead_code)]
317322
Git(GitCargoDependency),
318323
}
319324

src/domain/cargo_toml/snapshots/rust_crate_diffs__domain__cargo_toml__tests__new_from_buffer_creates_expected_config.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ source: src/domain/cargo_toml/tests.rs
33
expression: "format!(\"{outcome:?}\")"
44
snapshot_kind: text
55
---
6-
CargoTomlFile { dependencies: {"ahash": Simple("0.8.11"), "clap": Detailed(DetailedCargoDependency { version: "4.5.23" }), "clap-verbosity-flag": Simple("3.0.1"), "config": Simple("0.14.1"), "env_logger": Simple("0.11.5"), "git2": Simple("0.19.0"), "log": Simple("0.4.22"), "serde": Detailed(DetailedCargoDependency { version: "1.0.215" }), "sqlx": Detailed(DetailedCargoDependency { version: "0.8.2" })}, build_dependencies: None, dev_dependencies: Some({"assert_fs": Simple("1.1.2"), "trycmd": Simple("0.15.8")}) }
6+
File { dependencies: {"ahash": Simple("0.8.11"), "clap": Detailed(DetailedCargoDependency { version: "4.5.23" }), "clap-verbosity-flag": Simple("3.0.1"), "config": Simple("0.14.1"), "env_logger": Simple("0.11.5"), "git2": Simple("0.19.0"), "log": Simple("0.4.22"), "serde": Detailed(DetailedCargoDependency { version: "1.0.215" }), "sqlx": Detailed(DetailedCargoDependency { version: "0.8.2" })}, build_dependencies: None, dev_dependencies: Some({"assert_fs": Simple("1.1.2"), "trycmd": Simple("0.15.8")}) }

src/domain/cargo_toml/tests.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use assert_fs::{
77

88
use crate::domain::cargo_toml::{CargoDependencyValue, DetailedCargoDependency};
99

10-
use super::CargoTomlFile;
10+
use super::File;
1111

1212
fn get_temporary_cargo_toml_path(temp_dir: &TempDir) -> PathBuf {
1313
let cargo_toml_content = r#"[package]
@@ -50,8 +50,7 @@ fn new_successfully_parses_valid_cargo_toml_dependencies() {
5050
let temporary_cargo_toml_path = get_temporary_cargo_toml_path(&temp_dir);
5151

5252
// act
53-
let CargoTomlFile { dependencies, .. } =
54-
CargoTomlFile::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap();
53+
let File { dependencies, .. } = File::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap();
5554

5655
// assert
5756
assert_eq!(dependencies.len(), 9);
@@ -83,7 +82,7 @@ fn new_handles_missing_cargo_toml() {
8382
let temporary_cargo_toml_path = temp_dir.join("Cargoooo.toml");
8483

8584
// act
86-
let outcome = CargoTomlFile::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap_err();
85+
let outcome = File::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap_err();
8786

8887
// assert
8988
assert_eq!(
@@ -132,7 +131,7 @@ trycmd = "0.15.8"
132131
let temporary_cargo_toml_path = temp_dir.join("Cargo.toml");
133132

134133
// act
135-
let outcome = CargoTomlFile::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap_err();
134+
let outcome = File::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap_err();
136135

137136
// assert
138137
assert_eq!(
@@ -157,7 +156,7 @@ trycmd = "0.15.8"
157156
fn print_changes_versus_previous_version_advises_when_there_are_no_changes() {
158157
let temp_dir = assert_fs::TempDir::new().unwrap();
159158
let temporary_cargo_toml_path = get_temporary_cargo_toml_path(&temp_dir);
160-
let cargo_toml_file = CargoTomlFile::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap();
159+
let cargo_toml_file = File::new(temporary_cargo_toml_path.to_str().unwrap()).unwrap();
161160

162161
// act
163162
let output = cargo_toml_file
@@ -230,8 +229,8 @@ assert_fs = "1.1.2"
230229
trycmd = "0.15.8"
231230
"#;
232231

233-
let updated_cargo_toml = CargoTomlFile::new_from_str(updated_cargo_toml_content).unwrap();
234-
let earlier_cargo_toml = CargoTomlFile::new_from_str(earlier_cargo_toml_content).unwrap();
232+
let updated_cargo_toml = File::new_from_str(updated_cargo_toml_content).unwrap();
233+
let earlier_cargo_toml = File::new_from_str(earlier_cargo_toml_content).unwrap();
235234
// act
236235
let output = updated_cargo_toml
237236
.print_changes_versus_previous_version(&earlier_cargo_toml)
@@ -310,8 +309,8 @@ assert_fs = "1.1.2"
310309
trycmd = "0.15.8"
311310
"#;
312311

313-
let updated_cargo_toml = CargoTomlFile::new_from_str(updated_cargo_toml_content).unwrap();
314-
let earlier_cargo_toml = CargoTomlFile::new_from_str(earlier_cargo_toml_content).unwrap();
312+
let updated_cargo_toml = File::new_from_str(updated_cargo_toml_content).unwrap();
313+
let earlier_cargo_toml = File::new_from_str(earlier_cargo_toml_content).unwrap();
315314

316315
// act
317316
let output = updated_cargo_toml
@@ -389,8 +388,8 @@ assert_fs = "1.1.2"
389388
trycmd = "0.15.8"
390389
"#;
391390

392-
let updated_cargo_toml = CargoTomlFile::new_from_str(updated_cargo_toml_content).unwrap();
393-
let earlier_cargo_toml = CargoTomlFile::new_from_str(earlier_cargo_toml_content).unwrap();
391+
let updated_cargo_toml = File::new_from_str(updated_cargo_toml_content).unwrap();
392+
let earlier_cargo_toml = File::new_from_str(earlier_cargo_toml_content).unwrap();
394393

395394
// act
396395
let output = updated_cargo_toml
@@ -475,8 +474,8 @@ trycmd = "0.15.8"
475474
wiremock = "0.6.2"
476475
"#;
477476

478-
let updated_cargo_toml = CargoTomlFile::new_from_str(updated_cargo_toml_content).unwrap();
479-
let earlier_cargo_toml = CargoTomlFile::new_from_str(earlier_cargo_toml_content).unwrap();
477+
let updated_cargo_toml = File::new_from_str(updated_cargo_toml_content).unwrap();
478+
let earlier_cargo_toml = File::new_from_str(earlier_cargo_toml_content).unwrap();
480479

481480
// act
482481
let output = updated_cargo_toml
@@ -562,8 +561,8 @@ fs_extra = "1.3.0"
562561
glob = "0.3.1"
563562
"#;
564563

565-
let updated_cargo_toml = CargoTomlFile::new_from_str(updated_cargo_toml_content).unwrap();
566-
let earlier_cargo_toml = CargoTomlFile::new_from_str(earlier_cargo_toml_content).unwrap();
564+
let updated_cargo_toml = File::new_from_str(updated_cargo_toml_content).unwrap();
565+
let earlier_cargo_toml = File::new_from_str(earlier_cargo_toml_content).unwrap();
567566

568567
// act
569568
let output = updated_cargo_toml
@@ -624,7 +623,7 @@ fn new_from_buffer_creates_expected_config() {
624623
];
625624

626625
// act
627-
let outcome = CargoTomlFile::new_from_buffer(&buffer).unwrap();
626+
let outcome = File::new_from_buffer(&buffer).unwrap();
628627

629628
// assert
630629
insta::assert_snapshot!(format!("{outcome:?}"));

src/domain/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ pub mod cargo_toml;
33
pub mod repo;
44
pub mod semver;
55

6-
pub use cargo_toml::CargoTomlFile;
6+
pub use cargo_toml::File as CargoTomlFile;
77
pub use repo::Repo;
8-
pub use semver::SemverVersion;
8+
pub use semver::Version as SemverVersion;

0 commit comments

Comments
 (0)