Skip to content

Commit

Permalink
Merge pull request #201 from alexmaco/up
Browse files Browse the repository at this point in the history
Upgrade dependencies; use cargo 1.52.0 for the new resolver
  • Loading branch information
anderejd authored Mar 30, 2021
2 parents 8d1a264 + 85b873f commit 294f7a5
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 267 deletions.
363 changes: 153 additions & 210 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cargo-geiger-serde/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ version = "0.1.0"

[dependencies]
semver = { version = "0.11.0", features = ["serde"] }
serde = { version = "1.0.116", features = ["derive"] }
url = { version = "2.1.1", features = ["serde"] }
serde = { version = "1.0.125", features = ["derive"] }
url = { version = "2.2.1", features = ["serde"] }
32 changes: 16 additions & 16 deletions cargo-geiger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@ version = "0.10.2"
maintenance = { status = "experimental" }

[dependencies]
anyhow = "1.0.38"
cargo = "0.50.0"
anyhow = "1.0.40"
cargo = "0.52.0"
cargo-geiger-serde = { path = "../cargo-geiger-serde", version = "0.1.0" }
cargo_metadata = "0.12.3"
cargo_metadata = "0.13.1"
cargo-platform = "0.1.1"
colored = "2.0.0"
console = "0.11.3"
console = "0.14.1"
geiger = { path = "../geiger", version = "0.4.6" }
krates = "0.5.0"
krates = "0.7.0"
petgraph = "0.5.1"
pico-args = "0.4.0"
regex = "1.4.3"
serde = { version = "=1.0.121", features = ["derive"] }
serde_json = "1.0.61"
regex = "1.4.5"
serde = { version = "1.0.125", features = ["derive"] }
serde_json = "1.0.64"
strum = "0.20.0"
strum_macros = "0.20.1"
walkdir = "2.3.1"
url = "2.2.0"
walkdir = "2.3.2"
url = "2.2.1"

[features]
vendored-openssl = ["cargo/vendored-openssl"]

[dev-dependencies]
assert_cmd = "1.0.1"
assert_cmd = "1.0.3"
better-panic = "0.2.0"
fs_extra = "1.2.0"
insta = "1.7.0"
rand = "0.7.3"
regex = "1.3.9"
rstest = "0.6.4"
insta = "1.7.1"
rand = "0.8.3"
regex = "1.4.5"
rstest = "0.7.0"
semver = "0.11.0"
tempfile = "3.1.0"
tempfile = "3.2.0"
5 changes: 1 addition & 4 deletions cargo-geiger/src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ mod mapping_tests {
input_package_path_option: Option<&Path>,
expected_package_path_buf_option: Option<PathBuf>,
) {
let _mock_package_parent = match input_package_path_option {
Some(path) => Some(path),
None => None,
};
let _mock_package_parent = input_package_path_option;

let mock_package = MockPackage {
mock_package_name: String::from("package_name"),
Expand Down
12 changes: 6 additions & 6 deletions cargo-geiger/src/mapping/krates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,23 @@ mod krates_tests {
expected_package_name,
expected_package_version,
case(
"cargo_metadata:0.12.3",
"cargo_metadata:0.13.1",
"cargo_metadata",
Version {
major: 0,
minor: 12,
patch: 3,
minor: 13,
patch: 1,
pre: vec![],
build: vec![]
}
),
case(
"cargo_metadata:0.12.3",
"cargo_metadata:0.13.1",
"cargo_metadata",
Version {
major: 0,
minor: 12,
patch: 3,
minor: 13,
patch: 1,
pre: vec![],
build: vec![]
}
Expand Down
14 changes: 9 additions & 5 deletions cargo-geiger/src/mapping/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ mod metadata_tests {
use crate::mapping::metadata::dependency::GetDependencyInformation;
use crate::mapping::GetPackageRoot;

use cargo::core::dependency::DepKind;
use cargo::core::registry::PackageRegistry;
use cargo::core::resolver::ResolveOpts;
use cargo::core::{
dependency::DepKind, resolver::features::RequestedFeatures,
};
use cargo::core::{
Package, PackageId, PackageIdSpec, PackageSet, Resolve, Workspace,
};
Expand Down Expand Up @@ -236,7 +238,7 @@ mod metadata_tests {
.pop()
.unwrap();

assert!(
assert_eq!(
dependency
.matches_ignoring_source(&krates, &dependency_package_id)
.unwrap(),
Expand Down Expand Up @@ -318,9 +320,11 @@ mod metadata_tests {
let uses_default_features = !args.no_default_features;
let opts = ResolveOpts::new(
dev_deps,
&args.features.clone(),
args.all_features,
uses_default_features,
RequestedFeatures::from_command_line(
&args.features,
args.all_features,
uses_default_features,
),
);
let prev = ops::load_pkg_lockfile(workspace)?;
let resolve = ops::resolve_with_previous(
Expand Down
2 changes: 1 addition & 1 deletion cargo-geiger/src/mapping/metadata/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl GetPackageInformation for Package {
}

fn get_package_parent(&self) -> Option<&Path> {
self.manifest_path.parent()
self.manifest_path.parent().map(|p| p.as_ref())
}

fn get_package_version(&self) -> Version {
Expand Down
13 changes: 5 additions & 8 deletions cargo-geiger/src/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cargo::{CliError, CliResult};
use regex::Regex;
use std::fs::File;
use std::io::{BufRead, BufReader, Error, Write};
use std::path::PathBuf;
use std::path::{Path, PathBuf};

/// Name of README FILE
pub const README_FILENAME: &str = "README.md";
Expand Down Expand Up @@ -117,8 +117,8 @@ fn get_readme_path_buf_from_arguments_or_default(
}

/// Read the contents of a file line by line.
fn read_file_contents(path_buf: &PathBuf) -> Result<Vec<String>, Error> {
let file = File::open(path_buf)?;
fn read_file_contents(path: &Path) -> Result<Vec<String>, Error> {
let file = File::open(path)?;
let buf_reader = BufReader::new(file);

Ok(buf_reader
Expand Down Expand Up @@ -193,11 +193,8 @@ fn update_readme_content(
}

/// Write a Vec<String> line by line to a file, overwriting the current file, if it exists.
fn write_lines_to_file(
lines: &[String],
path_buf: &PathBuf,
) -> Result<(), Error> {
let mut readme_file = File::create(path_buf)?;
fn write_lines_to_file(lines: &[String], path: &Path) -> Result<(), Error> {
let mut readme_file = File::create(path)?;

for line in lines {
writeln!(readme_file, "{}", line)?
Expand Down
3 changes: 1 addition & 2 deletions cargo-geiger/src/scan/default/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ fn construct_key_lines(
emoji_symbols: &EmojiSymbols,
output_format: OutputFormat,
) -> Vec<String> {
let mut output_key_lines = Vec::<String>::new();
let mut output_key_lines = vec![String::new()];

output_key_lines.push(String::new());
match output_format {
OutputFormat::Ratio => {
// Change the prompt for Safe Ratio report:
Expand Down
7 changes: 4 additions & 3 deletions cargo-geiger/src/scan/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn find_rs_files_in_packages(
fn handle_unsafe_in_file_error(
allow_partial_results: bool,
error: ScanFileError,
path_buf: &PathBuf,
path_buf: &Path,
) {
if allow_partial_results {
eprintln!("Failed to parse file: {}, {:?} ", path_buf.display(), error);
Expand Down Expand Up @@ -316,16 +316,17 @@ mod find_tests {
input_is_entry_point,
package.id.clone(),
&mut package_id_to_metrics,
package.manifest_path.clone(),
package.manifest_path.clone().into(),
rs_file_metrics.clone(),
);

assert!(package_id_to_metrics.contains_key(&package.id));
let package_metrics = package_id_to_metrics.get(&package.id).unwrap();

let manifest_path: &Path = package.manifest_path.as_path().as_ref();
let wrapper = package_metrics
.rs_path_to_metrics
.get(package.manifest_path.as_path())
.get(manifest_path)
.unwrap();

assert_eq!(wrapper.metrics, rs_file_metrics);
Expand Down
5 changes: 1 addition & 4 deletions cargo-geiger/src/scan/forbid/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ pub fn scan_forbid_to_table(
}

fn construct_key_lines(emoji_symbols: &EmojiSymbols) -> Vec<String> {
let mut output_key_lines = Vec::<String>::new();

output_key_lines.push(String::new());
output_key_lines.push(String::from("Symbols: "));
let mut output_key_lines = vec![String::new(), String::from("Symbols: ")];

let forbids = "All entry point .rs files declare #![forbid(unsafe_code)].";
let unknown = "This crate may use unsafe code.";
Expand Down
4 changes: 2 additions & 2 deletions cargo-geiger/src/scan/rs_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ pub fn into_rs_code_file(target_kind: &TargetKind, path: PathBuf) -> RsFile {
}

/// `cargo_metadata` returns the serialized strings from
/// https://github.com/rust-lang/cargo/blob/master/src/cargo/core/manifest.rs#L122
/// <https://github.com/rust-lang/cargo/blob/master/src/cargo/core/manifest.rs#L122>
/// `TargetKind::ExampleBin` and `TargetKind::ExampleLib`, are both handled in the same manner
/// within `cargo-geiger`.
/// If at a future date, we need to separate these two, the information from
/// https://github.com/oli-obk/cargo_metadata/blob/540fc6cd8ea1624055c98faf92ef61f620b6aa8f/src/lib.rs#L400
/// <https://github.com/oli-obk/cargo_metadata/blob/540fc6cd8ea1624055c98faf92ef61f620b6aa8f/src/lib.rs#L400>
/// can be used to improve this function.
pub fn into_target_kind(raw_target_kind: Vec<String>) -> TargetKind {
let raw_target_kind_str = raw_target_kind
Expand Down
8 changes: 4 additions & 4 deletions geiger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ maintenance = { status = "experimental" }

[dependencies]
cargo-geiger-serde = { path = "../cargo-geiger-serde", version = "0.1.0" }
syn = { version = "1.0.53", features = ["parsing", "printing", "clone-impls", "full", "extra-traits", "visit"] }
proc-macro2 = "1.0.18"
syn = { version = "1.0.67", features = ["parsing", "printing", "clone-impls", "full", "extra-traits", "visit"] }
proc-macro2 = "1.0.24"

[dev-dependencies]
rstest = "0.6.4"
tempfile = "3.1.0"
rstest = "0.7.0"
tempfile = "3.2.0"

0 comments on commit 294f7a5

Please sign in to comment.