Skip to content

Commit

Permalink
ISSUE-16 - Making PR requested changes:
Browse files Browse the repository at this point in the history
* Updating usages of `krates::Builder` to KratesBuilder
* Removing commented out code
* Making requested changes from a later version of clippy

Signed-off-by: joshmc <[email protected]>
  • Loading branch information
jmcconnell26 committed Nov 14, 2020
1 parent 5f8322b commit de5a5f1
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cargo-geiger/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn parse_features(raw_features: Option<String>) -> Vec<String> {
.unwrap_or_else(String::new)
.split(' ')
.map(str::to_owned)
.filter(|f| f != "")
.filter(|f| !f.is_empty())
.collect::<Vec<String>>()
}

Expand Down
6 changes: 4 additions & 2 deletions cargo-geiger/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use cargo::util::{self, important_paths, CargoResult};
use cargo::Config;
use cargo_metadata::{CargoOpt, Metadata, MetadataCommand};
use cargo_platform::Cfg;
use krates::{Builder, Krates};
use krates::Builder as KratesBuilder;
use krates::Krates;
use std::path::PathBuf;
use std::str::{self, FromStr};

Expand Down Expand Up @@ -83,7 +84,8 @@ pub fn get_cfgs(
}

pub fn get_krates(cargo_metadata: &Metadata) -> CargoResult<Krates> {
Ok(Builder::new().build_with_metadata(cargo_metadata.clone(), |_| ())?)
Ok(KratesBuilder::new()
.build_with_metadata(cargo_metadata.clone(), |_| ())?)
}

pub fn get_registry<'a>(
Expand Down
4 changes: 2 additions & 2 deletions cargo-geiger/src/format/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub mod display_tests {

use cargo::core::manifest::ManifestMetadata;
use cargo_metadata::{CargoOpt, MetadataCommand};
use krates::Builder;
use krates::Builder as KratesBuilder;
use rstest::*;

#[rstest(
Expand Down Expand Up @@ -94,7 +94,7 @@ pub mod display_tests {
.exec()
.unwrap();

let krates = Builder::new()
let krates = KratesBuilder::new()
.build_with_metadata(metadata.clone(), |_| ())
.unwrap();

Expand Down
26 changes: 17 additions & 9 deletions cargo-geiger/src/format/print_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ mod print_config_tests {
input_invert_bool: bool,
expected_edge_direction: EdgeDirection,
) {
let mut args = Args::default();
args.invert = input_invert_bool;
let args = Args {
invert: input_invert_bool,
.. Default::default()
};

let print_config_result = PrintConfig::new(&args);

Expand All @@ -144,8 +146,10 @@ mod print_config_tests {
input_include_tests_bool: bool,
expected_include_tests: IncludeTests,
) {
let mut args = Args::default();
args.include_tests = input_include_tests_bool;
let args = Args {
include_tests: input_include_tests_bool,
.. Default::default()
};

let print_config_result = PrintConfig::new(&args);

Expand All @@ -170,9 +174,11 @@ mod print_config_tests {
input_no_indent_bool: bool,
expected_output_prefix: Prefix,
) {
let mut args = Args::default();
args.prefix_depth = input_prefix_depth_bool;
args.no_indent = input_no_indent_bool;
let args = Args {
no_indent: input_no_indent_bool,
prefix_depth: input_prefix_depth_bool,
.. Default::default()
};

let print_config_result = PrintConfig::new(&args);

Expand All @@ -191,8 +197,10 @@ mod print_config_tests {
input_verbosity_u32: u32,
expected_verbosity: Verbosity,
) {
let mut args = Args::default();
args.verbose = input_verbosity_u32;
let args = Args {
verbose: input_verbosity_u32,
.. Default::default()
};

let print_config_result = PrintConfig::new(&args);

Expand Down
2 changes: 2 additions & 0 deletions cargo-geiger/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum ExtraDeps {
}

impl ExtraDeps {
// This clippy recommendation is valid, but makes this function much harder to read
#[allow(clippy::match_like_matches_macro)]
pub fn allows(&self, dep: DependencyKind) -> bool {
match (self, dep) {
(_, DependencyKind::Normal) => true,
Expand Down
9 changes: 5 additions & 4 deletions cargo-geiger/src/scan/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ mod default_tests {
input_features: Vec<String>,
expected_compile_features: Vec<&str>,
) {
let mut args = FeaturesArgs::default();
args.all_features = rand::random();
args.features = input_features;
args.no_default_features = rand::random();
let args = FeaturesArgs{
all_features: rand::random(),
features: input_features,
no_default_features: rand::random()
};

let config = Config::default().unwrap();
let compile_options = build_compile_options(&args, &config);
Expand Down
6 changes: 0 additions & 6 deletions cargo-geiger/src/scan/forbid/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ fn handle_package_text_tree_line(
let sym_lock = emoji_symbols.emoji(SymbolKind::Lock);
let sym_qmark = emoji_symbols.emoji(SymbolKind::QuestionMark);

/*let package = package_set
.get_one(
package_id
.to_package_id(cargo_metadata_parameters.krates, package_set),
)
.unwrap(); // FIXME*/
let name = format_package_name(
cargo_metadata_parameters,
&package_id,
Expand Down
5 changes: 3 additions & 2 deletions cargo-geiger/src/utils/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ mod core_tests {

use cargo::Config;
use cargo_metadata::{CargoOpt, Metadata, MetadataCommand};
use krates::{Builder, Krates};
use krates::Builder as KratesBuilder;
use krates::Krates;
use rstest::*;
use std::path::PathBuf;

Expand Down Expand Up @@ -130,7 +131,7 @@ mod core_tests {
.exec()
.unwrap();

let krates = Builder::new()
let krates = KratesBuilder::new()
.build_with_metadata(metadata.clone(), |_| ())
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions cargo-geiger/src/utils/krates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod krates_tests {
use super::*;

use cargo_metadata::{CargoOpt, Metadata, MetadataCommand};
use krates::Builder;
use krates::Builder as KratesBuilder;
use rstest::*;

#[rstest]
Expand Down Expand Up @@ -72,7 +72,7 @@ mod krates_tests {
.exec()
.unwrap();

let krates = Builder::new()
let krates = KratesBuilder::new()
.build_with_metadata(metadata.clone(), |_| ())
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions cargo-geiger/src/utils/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod metadata_tests {

use cargo::Config;
use cargo_metadata::{CargoOpt, Metadata, MetadataCommand};
use krates::Builder;
use krates::Builder as KratesBuilder;
use rstest::*;
use std::path::PathBuf;

Expand Down Expand Up @@ -305,7 +305,7 @@ mod metadata_tests {
.exec()
.unwrap();

let krates = Builder::new()
let krates = KratesBuilder::new()
.build_with_metadata(metadata.clone(), |_| ())
.unwrap();

Expand Down

0 comments on commit de5a5f1

Please sign in to comment.