Skip to content

Commit 4db2d70

Browse files
committed
apply just all +stable clippy --fix
1 parent 6f0c181 commit 4db2d70

9 files changed

+26
-28
lines changed

cli/src/crawl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ pub fn crawl(
4141
Err(error) => {
4242
if let IgnoreError::WithPath { path, err } = error {
4343
FileResult::from_error(&path.to_string_lossy(), err)
44-
.print_as(&output_format, true);
44+
.print_as(output_format, true);
4545
} else {
46-
FileResult::from_error("", error).print_as(&output_format, false);
46+
FileResult::from_error("", error).print_as(output_format, false);
4747
}
4848
None
4949
}
@@ -58,10 +58,10 @@ pub fn crawl(
5858
let data = TextData::new(&content);
5959
let idres = identify_data(&store, &data, false, false);
6060
let fileres = FileResult::from_identification_result(&path_lossy, &idres);
61-
fileres.print_as(&output_format, true);
61+
fileres.print_as(output_format, true);
6262
}
6363
Err(err) => {
64-
FileResult::from_error(&path_lossy, err).print_as(&output_format, true);
64+
FileResult::from_error(&path_lossy, err).print_as(output_format, true);
6565
}
6666
};
6767
});

cli/src/formats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'a> FileResult<'a> {
4949
result: &'a Result<CLIIdentification, Error>,
5050
) -> FileResult<'a> {
5151
match result {
52-
Ok(id) => FileResult::Ok { path, result: &id },
52+
Ok(id) => FileResult::Ok { path, result: id },
5353
Err(e) => FileResult::Err {
5454
path,
5555
error: format!("{}", e),

cli/src/identify.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn identify(
4747
let idres = identify_data(&store, &content.into(), optimize, want_diff);
4848
let file_lossy = filename.to_string_lossy();
4949
let fileres = FileResult::from_identification_result(&file_lossy, &idres);
50-
fileres.print_as(&output_format, false);
50+
fileres.print_as(output_format, false);
5151

5252
return idres.map(|_| ());
5353
}
@@ -69,14 +69,14 @@ pub fn identify(
6969
path: &buf,
7070
error: format!("Input error: {}", e),
7171
};
72-
fileres.print_as(&output_format, false);
72+
fileres.print_as(output_format, false);
7373
continue;
7474
}
7575
};
7676

7777
let idres = identify_data(&store, &content.into(), optimize, want_diff);
7878
let fileres = FileResult::from_identification_result(&buf, &idres);
79-
fileres.print_as(&output_format, false);
79+
fileres.print_as(output_format, false);
8080
}
8181

8282
Ok(())
@@ -113,7 +113,7 @@ pub fn identify_data(
113113
.map(|cr| CLIContainedResult {
114114
score: cr.score,
115115
license: CLIIdentifiedLicense {
116-
aliases: store.aliases(&cr.license.name).unwrap().clone(),
116+
aliases: store.aliases(cr.license.name).unwrap().clone(),
117117
name: cr.license.name.to_owned(),
118118
kind: cr.license.kind,
119119
},
@@ -125,13 +125,13 @@ pub fn identify_data(
125125
// include the overall license if present
126126
if let Some(license) = result.license {
127127
output.license = Some(CLIIdentifiedLicense {
128-
aliases: store.aliases(&license.name).unwrap().clone(),
128+
aliases: store.aliases(license.name).unwrap().clone(),
129129
name: license.name.to_owned(),
130130
kind: license.kind,
131131
});
132132

133133
if want_diff {
134-
diff_result(&text_data, &license.data);
134+
diff_result(text_data, license.data);
135135
}
136136

137137
return Ok(output);
@@ -140,7 +140,7 @@ pub fn identify_data(
140140
// not a good enough match overall, but maybe inside
141141
if !output.containing.is_empty() {
142142
if want_diff {
143-
diff_result(&text_data, &result.containing[0].license.data);
143+
diff_result(text_data, result.containing[0].license.data);
144144
}
145145
return Ok(output);
146146
}

cli/tests/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use serde_json;
4+
55

66
use std::path::PathBuf;
77
use std::process::Command;

src/license.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -311,23 +311,23 @@ mod tests {
311311

312312
let (optimized, _) = sample.optimize_bounds(&license);
313313
println!("{:?}", optimized.lines_view);
314-
println!("{:?}", optimized.lines_normalized.clone());
314+
println!("{:?}", optimized.lines_normalized);
315315
assert_eq!((0, 3), optimized.lines_view);
316316

317317
// add more to the string, try again (avoid int trunc screwups)
318318
let sample_text = format!("{}\none more line", sample_text);
319319
let sample = TextData::from(sample_text.as_str());
320320
let (optimized, _) = sample.optimize_bounds(&license);
321321
println!("{:?}", optimized.lines_view);
322-
println!("{:?}", optimized.lines_normalized.clone());
322+
println!("{:?}", optimized.lines_normalized);
323323
assert_eq!((0, 3), optimized.lines_view);
324324

325325
// add to the beginning too
326326
let sample_text = format!("some content\nat\n\nthe beginning\n{}", sample_text);
327327
let sample = TextData::from(sample_text.as_str());
328328
let (optimized, _) = sample.optimize_bounds(&license);
329329
println!("{:?}", optimized.lines_view);
330-
println!("{:?}", optimized.lines_normalized.clone());
330+
println!("{:?}", optimized.lines_normalized);
331331
// end bounds at 7 and 8 have the same score, since they're empty lines (not
332332
// counted). askalono is not smart enough to trim this as close as it
333333
// can.

src/strategy.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl<'a> ScanStrategy<'a> {
386386
#[cfg(test)]
387387
mod tests {
388388
use super::*;
389-
use env_logger;
389+
390390

391391
#[test]
392392
fn can_construct() {
@@ -411,7 +411,7 @@ mod tests {
411411
let result = strategy.scan(&test_data).unwrap();
412412
assert!(
413413
result.score > 0.5,
414-
format!("score must meet threshold; was {}", result.score)
414+
"score must meet threshold; was {}", result.score
415415
);
416416
assert_eq!(
417417
result.license.expect("result has a license").name,
@@ -471,8 +471,8 @@ mod tests {
471471
// inspect the array and ensure we got both licenses
472472
let mut found1 = 0;
473473
let mut found2 = 0;
474-
for (_, ref contained) in result.containing.iter().enumerate() {
475-
match contained.license.name.as_ref() {
474+
for (_, contained) in result.containing.iter().enumerate() {
475+
match contained.license.name {
476476
"license-1" => {
477477
assert!(contained.score > 0.5, "license-1 score meets threshold");
478478
found1 += 1;
@@ -516,8 +516,8 @@ mod tests {
516516
// inspect the array and ensure we got both licenses
517517
let mut found1 = 0;
518518
let mut found2 = 0;
519-
for (_, ref contained) in result.containing.iter().enumerate() {
520-
match contained.license.name.as_ref() {
519+
for (_, contained) in result.containing.iter().enumerate() {
520+
match contained.license.name {
521521
"license-1" => {
522522
assert!(contained.score > 0.5, "license-1 score meets threshold");
523523
found1 += 1;

tests/introspection.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// express or implied. See the License for the specific language governing
1212
// permissions and limitations under the License.
1313

14-
use askalono;
15-
1614
mod common;
1715

1816
use std::fs::File;
@@ -38,7 +36,7 @@ fn self_apache_header() {
3836
assert_eq!(askalono::LicenseType::Header, matched.license_type);
3937

4038
// now try to find the bounds of the license header
41-
let (optimized, _) = text_data.optimize_bounds(&matched.data);
39+
let (optimized, _) = text_data.optimize_bounds(matched.data);
4240

4341
// the license is from (0-indexed) lines 3 thru 12 of this file, excluding
4442
// that copyright statement on line 1.

tests/real_world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn real_world_licenses() {
3030
let test_name = &parts[0];
3131
let confidence = f32::from_str(parts[1]).unwrap();
3232

33-
assert_license(&store, &file_path, &test_name, &license_id, confidence);
33+
assert_license(&store, &file_path, test_name, &license_id, confidence);
3434
}
3535
}
3636
}

tests/store_sanity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use askalono::TextData;
1111
#[test]
1212
fn store_loads() {
1313
let store = common::load_store();
14-
assert!(store.len() > 0, "store should have licenses");
14+
assert!(!store.is_empty(), "store should have licenses");
1515
}
1616

1717
#[test]
@@ -26,7 +26,7 @@ fn self_licenses() {
2626
"MPL-2.0",
2727
] {
2828
let mut f = File::open(format!("{}/{}.txt", common::SPDX_TEXT, license))
29-
.expect(&format!("couldn't open license file '{}'", license));
29+
.unwrap_or_else(|_| panic!("couldn't open license file '{}'", license));
3030
let mut text = String::new();
3131
f.read_to_string(&mut text).unwrap();
3232
let text_data: TextData = text.into();

0 commit comments

Comments
 (0)