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 crate version & clippy lints to compile with Rust version 1.76.0 #529

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/cache-zigs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
outputs:
matrix-json: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
repository: rinse-repeat/zig-gh-helper
path: zig-helper
Expand Down
31 changes: 17 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,30 @@ jobs:
# MacOS
- runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.76.0
- run: cargo test -- --skip args::args_tests::update_config_test_color_choice::case_4 --skip test_package

# TODO: Address clippy
# clippy:
# name: Check that clippy is happy
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/[email protected]
# with:
# components: clippy
# - run: cargo clippy --target x86_64-unknown-linux-gnu --all-features
clippy:
name: Check that clippy is happy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.76.0
components: clippy
- run: cargo clippy --workspace --all-features --all-targets --no-deps -- -D warnings

rustfmt:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.76.0
components: rustfmt
- run: cargo fmt --all -- --check
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
outputs:
matrix-json: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: release-repo
- id: set-matrix
Expand Down
34 changes: 14 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cargo-geiger-serde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! This crate provides definitions to serialize the unsafety report.

#![forbid(unsafe_code)]
#![deny(warnings)]

mod package_id;
mod report;
Expand Down
2 changes: 1 addition & 1 deletion cargo-geiger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ maintenance = { status = "experimental" }
anyhow = "1.0.70"
cargo = "0.75.1"
cargo-geiger-serde = { path = "../cargo-geiger-serde", version = "0.2.3" }
cargo_metadata = "0.18.1"
cargo_metadata = "0.15.4"
cargo-platform = "0.1.2"
colored = "2.0.0"
console = "0.15.5"
Expand Down
9 changes: 2 additions & 7 deletions cargo-geiger/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,14 @@ pub struct ReadmeArgs {
pub update_readme: bool,
}

#[derive(Debug, Eq, PartialEq)]
#[derive(Debug, Default, Eq, PartialEq)]
pub enum Verbosity {
#[default]
Verbose,
Normal,
Quiet,
}

impl Default for Verbosity {
fn default() -> Self {
Verbose
}
}

fn parse_features(raw_features: Option<String>) -> Vec<String> {
raw_features
.as_ref()
Expand Down
9 changes: 2 additions & 7 deletions cargo-geiger/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ use std::fmt;
use std::str::{self, FromStr};
use strum_macros::EnumIter;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Default, Debug, Eq, PartialEq)]
pub enum Charset {
#[default]
Ascii,
GitHubMarkdown,
Utf8,
}

impl Default for Charset {
fn default() -> Self {
Charset::Ascii
}
}

#[derive(Debug, Eq, PartialEq)]
pub enum Chunk {
License,
Expand Down
9 changes: 2 additions & 7 deletions cargo-geiger/src/format/print_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,16 @@ pub enum Prefix {
None,
}

#[derive(Clone, Copy, Debug, EnumString, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Default, EnumString, Eq, PartialEq)]
pub enum OutputFormat {
Ascii,
Json,
GitHubMarkdown,
Ratio,
#[default]
Utf8,
}

impl Default for OutputFormat {
fn default() -> Self {
OutputFormat::Utf8
}
}

#[derive(Debug, Eq, PartialEq)]
pub struct PrintConfig {
/// Don't truncate dependencies that have already been displayed.
Expand Down
1 change: 0 additions & 1 deletion cargo-geiger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![deny(clippy::cargo)]
#![deny(clippy::doc_markdown)]
#![forbid(unsafe_code)]
#![deny(warnings)]

/// Argument parsing
pub mod args;
Expand Down
1 change: 0 additions & 1 deletion cargo-geiger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#![deny(clippy::cargo)]
#![deny(clippy::doc_markdown)]
#![forbid(unsafe_code)]
#![deny(warnings)]

extern crate cargo;
extern crate colored;
Expand Down
2 changes: 1 addition & 1 deletion cargo-geiger/src/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn read_file_contents(path: &Path) -> Result<Vec<String>, Error> {

Ok(buf_reader
.lines()
.filter_map(|l| l.ok())
.map_while(Result::ok)
.collect::<Vec<String>>())
}

Expand Down
8 changes: 4 additions & 4 deletions cargo-geiger/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ fn list_files_used_but_not_scanned(

rs_files_used
.iter()
.cloned()
.filter(|p| {
!scanned_files.contains(p)
&& !geiger_context.ignored_paths.contains(p)
&& !geiger_context.ignored_paths.contains(*p)
})
.cloned()
.collect()
}

Expand Down Expand Up @@ -357,7 +357,7 @@ mod scan_tests {
&mut visited,
);

assert_eq!(visited, vec![dependency_index].iter().cloned().collect());
assert_eq!(visited, [dependency_index].iter().cloned().collect());
assert_eq!(
package_info.dependencies.len(),
expected_package_info_dependency_length
Expand Down Expand Up @@ -446,7 +446,7 @@ mod scan_tests {
input_rs_path_to_metrics_vec.iter().cloned().collect();

let geiger_context = GeigerContext {
package_id_to_metrics: vec![(
package_id_to_metrics: [(
package_id,
PackageMetrics { rs_path_to_metrics },
)]
Expand Down
8 changes: 3 additions & 5 deletions cargo-geiger/src/scan/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::format::print_config::PrintConfig;
use crate::mapping::{CargoMetadataParameters, GetPackageRoot};
use crate::scan::rs_file::{
into_is_entry_point_and_path_buf, into_rs_code_file, into_target_kind,
is_file_with_ext, RsFile, RsFileMetricsWrapper,
is_file_with_ext, RsFile,
};
use crate::scan::PackageMetrics;

Expand Down Expand Up @@ -236,13 +236,11 @@ fn update_package_id_to_metrics_with_rs_file_metrics(
path_buf: PathBuf,
rs_file_metrics: RsFileMetrics,
) {
let package_metrics = package_id_to_metrics
.entry(package_id)
.or_insert_with(PackageMetrics::default);
let package_metrics = package_id_to_metrics.entry(package_id).or_default();
let wrapper = package_metrics
.rs_path_to_metrics
.entry(path_buf)
.or_insert_with(RsFileMetricsWrapper::default);
.or_default();
wrapper.metrics = rs_file_metrics;
wrapper.is_crate_entry_point = is_entry_point;
}
Expand Down
6 changes: 3 additions & 3 deletions cargo-geiger/src/scan/rs_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn add_dir_entries_to_path_buf_hash_set(
path_buf_hash_set: &mut HashSet<PathBuf>,
workspace_root: PathBuf,
) -> Result<(), RsResolveError> {
for entry in WalkDir::new(&out_dir) {
for entry in WalkDir::new(out_dir) {
let entry = entry.map_err(RsResolveError::Walkdir)?;
if !is_file_with_ext(&entry, "d") {
continue;
Expand Down Expand Up @@ -423,7 +423,7 @@ mod rs_file_tests {
let config = Config::default().unwrap();
let cwd = config.cwd();

let walk_dir_rust_files = WalkDir::new(&cwd)
let walk_dir_rust_files = WalkDir::new(cwd)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| e.path().to_str().unwrap().ends_with(".rs"));
Expand All @@ -432,7 +432,7 @@ mod rs_file_tests {
assert!(is_file_with_ext(&entry, "rs"));
}

let walk_dir_readme_files = WalkDir::new(&cwd)
let walk_dir_readme_files = WalkDir::new(cwd)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| e.path().to_str().unwrap().contains("README"));
Expand Down
4 changes: 2 additions & 2 deletions cargo-geiger/src/tree/traversal/dependency_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub fn walk_dependency_node(
all_out_text_tree_lines
}

fn construct_dependency_type_nodes_hashmap<'a>(
graph: &'a Graph,
fn construct_dependency_type_nodes_hashmap(
graph: &Graph,
package: &PackageId,
print_config: &PrintConfig,
) -> HashMap<DependencyKind, Vec<PackageId>> {
Expand Down
2 changes: 1 addition & 1 deletion cargo-geiger/tests/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Context {
content_only: true,
..Default::default()
};
fs_extra::dir::copy(&src_path, dir.path(), &copy_options)
fs_extra::dir::copy(src_path, dir.path(), &copy_options)
.expect("Failed to copy tests");
let path = dir
.path()
Expand Down
1 change: 0 additions & 1 deletion geiger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! from `cargo`.

#![forbid(unsafe_code)]
#![deny(warnings)]

pub mod find;
pub use find::*; // preserve APIs
Expand Down
Loading