Skip to content

Commit 0a0a684

Browse files
committed
Fix pre-commits
1 parent 1e5a4a2 commit 0a0a684

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

src/lib.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ pub type CliInput<'a> = (
2929
);
3030
pub type CheckOutput = (Vec<LicenseInfo>, Vec<LicenseInfo>);
3131

32-
pub fn fetch_license_infos(
33-
cli_input: CliInput,
34-
) -> Result<LicenseInfos> {
35-
36-
let (conda_deny_config, cli_lockfiles, cli_platforms, cli_environments, conda_prefixes, _) = cli_input;
32+
pub fn fetch_license_infos(cli_input: CliInput) -> Result<LicenseInfos> {
33+
let (conda_deny_config, cli_lockfiles, cli_platforms, cli_environments, conda_prefixes, _) =
34+
cli_input;
3735

3836
if conda_prefixes.is_empty() {
3937
LicenseInfos::get_license_infos_from_config(
@@ -44,22 +42,23 @@ pub fn fetch_license_infos(
4442
)
4543
.with_context(|| "Getting license information from config file failed.")
4644
} else {
47-
LicenseInfos::from_conda_prefixes(conda_prefixes).with_context(|| {
48-
"Getting license information from conda prefixes failed."
49-
})
45+
LicenseInfos::from_conda_prefixes(conda_prefixes)
46+
.with_context(|| "Getting license information from conda prefixes failed.")
5047
}
5148
}
5249

5350
pub fn list(cli_input: CliInput) -> Result<()> {
54-
let license_infos = fetch_license_infos(cli_input).with_context(|| "Fetching license information failed.")?;
51+
let license_infos =
52+
fetch_license_infos(cli_input).with_context(|| "Fetching license information failed.")?;
5553
license_infos.list();
5654
Ok(())
5755
}
5856

5957
pub fn check_license_infos(cli_input: CliInput) -> Result<CheckOutput> {
6058
let (conda_deny_config, _, _, _, _, osi) = cli_input;
6159

62-
let license_infos = fetch_license_infos(cli_input).with_context(|| "Fetching license information failed.")?;
60+
let license_infos =
61+
fetch_license_infos(cli_input).with_context(|| "Fetching license information failed.")?;
6362

6463
if osi {
6564
debug!("Checking licenses for OSI compliance");

src/license_info.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ impl LicenseInfos {
217217

218218
pub fn get_license_infos_from_config(
219219
config: &CondaDenyConfig,
220-
cli_lockfiles: &Vec<String>,
221-
cli_platforms: &Vec<String>,
222-
cli_environments: &Vec<String>,
220+
cli_lockfiles: &[String],
221+
cli_platforms: &[String],
222+
cli_environments: &[String],
223223
) -> Result<LicenseInfos> {
224224
let mut platforms = config.get_platform_spec().map_or(vec![], |p| p);
225225
let mut lockfiles = config.get_lockfile_spec();
226226
let mut environment_specs = config.get_environment_spec().map_or(vec![], |e| e);
227227

228-
platforms.extend(cli_platforms.clone());
229-
lockfiles.extend(cli_lockfiles.clone());
230-
environment_specs.extend(cli_environments.clone());
228+
platforms.extend(cli_platforms.to_owned());
229+
lockfiles.extend(cli_lockfiles.to_owned());
230+
environment_specs.extend(cli_environments.to_owned());
231231

232232
LicenseInfos::from_pixi_lockfiles(lockfiles, platforms, environment_specs)
233233
}
@@ -469,8 +469,7 @@ mod tests {
469469
"tests/test_pyproject_toml_files/"
470470
);
471471
let config = CondaDenyConfig::from_path(&test_file_path).expect("Failed to read config");
472-
let license_infos =
473-
LicenseInfos::get_license_infos_from_config(&config, &vec![], &vec![], &vec![]);
472+
let license_infos = LicenseInfos::get_license_infos_from_config(&config, &[], &[], &[]);
474473
assert_eq!(license_infos.unwrap().license_infos.len(), 396);
475474
}
476475
}

src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ fn main() -> Result<()> {
7474
include_safe,
7575
osi: _,
7676
} => {
77-
7877
debug!("Check command called.");
7978

8079
if include_safe {

tests/integration_tests.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ mod tests {
9999
fn test_prefix_list() {
100100
// When --prefix is specified, only the license information for the conda-meta directory in the specified prefix should be listed
101101
// License information from pixi.lock should not be listed
102-
102+
103103
let test_dir = Path::new("tests/test_end_to_end/test_prefix_list");
104-
104+
105105
let output = Command::cargo_bin("conda-deny")
106106
.unwrap()
107107
.arg("list")
@@ -110,16 +110,22 @@ mod tests {
110110
.current_dir(test_dir)
111111
.output()
112112
.expect("Failed to execute command");
113-
114-
assert!(output.status.success(), "Command did not execute successfully");
115-
113+
114+
assert!(
115+
output.status.success(),
116+
"Command did not execute successfully"
117+
);
118+
116119
let stdout = str::from_utf8(&output.stdout).expect("Failed to convert output to string");
117-
120+
118121
let line_count = stdout.lines().count();
119122

120123
let expected_line_count = 50;
121-
assert_eq!(line_count, expected_line_count, "Unexpected number of output lines");
122-
124+
assert_eq!(
125+
line_count, expected_line_count,
126+
"Unexpected number of output lines"
127+
);
128+
123129
println!("Output has {} lines", line_count);
124130
}
125131
}

0 commit comments

Comments
 (0)