clippy: fix most of: argument is passed by value, but not consumed in the function body

This commit is contained in:
Graham Christensen 2019-01-02 17:13:44 -05:00
parent 0c0cf89dbd
commit 7eb3b81f56
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
7 changed files with 48 additions and 48 deletions

View file

@ -45,7 +45,7 @@ fn main() {
let mrw = tasks::massrebuilder::MassRebuildWorker::new(
cloner,
nix,
&nix,
cfg.github(),
cfg.acl(),
cfg.runner.identity.clone(),

View file

@ -29,7 +29,7 @@ pub struct CachedProjectCo {
}
impl CachedCloner {
pub fn project(&self, name: String, clone_url: String) -> CachedProject {
pub fn project(&self, name: &str, clone_url: String) -> CachedProject {
// <root>/repo/<hash>/clone
// <root>/repo/<hash>/clone.lock
// <root>/repo/<hash>/<type>/<id>
@ -290,7 +290,7 @@ mod tests {
let hash = make_pr_repo(&bare.path(), &mk_co.path());
let cloner = cached_cloner(&workingdir.path());
let project = cloner.project("commit-msg-list".to_owned(), bare.string());
let project = cloner.project("commit-msg-list", bare.string());
let working_co = project
.clone_for("testing-commit-msgs".to_owned(), "123".to_owned())
.expect("clone should work");
@ -317,7 +317,7 @@ mod tests {
let hash = make_pr_repo(&bare.path(), &mk_co.path());
let cloner = cached_cloner(&workingdir.path());
let project = cloner.project("commit-files-changed-list".to_owned(), bare.string());
let project = cloner.project("commit-files-changed-list", bare.string());
let working_co = project
.clone_for("testing-files-changed".to_owned(), "123".to_owned())
.expect("clone should work");

View file

@ -77,7 +77,7 @@ impl PkgsAddedRemovedTagger {
t
}
pub fn changed(&mut self, removed: Vec<PackageArch>, added: Vec<PackageArch>) {
pub fn changed(&mut self, removed: &[PackageArch], added: &[PackageArch]) {
if removed.len() > 0 {
self.selected.push(String::from("8.has: clean-up"));
}

View file

@ -302,7 +302,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
info!("Working on {}", job.pr.number);
let project = self.cloner.project(
job.repo.full_name.clone(),
&job.repo.full_name,
job.repo.clone_url.clone(),
);
let co = project

View file

@ -99,7 +99,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime<Utc>) -> Chec
let mut summary: Vec<String> = vec![];
if let Some(ref attempted) = result.attempted_attrs {
summary.extend(list_segment("Attempted", attempted.clone()));
summary.extend(list_segment("Attempted", &attempted));
}
if result.status == BuildStatus::TimedOut {
@ -112,7 +112,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime<Utc>) -> Chec
"The following builds were skipped because they don't evaluate on {}",
result.system
),
skipped.clone()));
&skipped));
}
let text: String;
@ -193,7 +193,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String {
reply.push("".to_owned());
if let Some(ref attempted) = result.attempted_attrs {
reply.extend(list_segment("Attempted", attempted.clone()));
reply.extend(list_segment("Attempted", &attempted));
}
if let Some(ref skipped) = result.skipped_attrs {
@ -202,7 +202,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String {
"The following builds were skipped because they don't evaluate on {}",
result.system
),
skipped.clone()));
&skipped));
}
if result.output.len() > 0 {
@ -217,7 +217,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String {
reply.join("\n")
}
fn list_segment(name: &str, things: Vec<String>) -> Vec<String> {
fn list_segment(name: &str, things: &[String]) -> Vec<String> {
let mut reply: Vec<String> = vec![];
if things.len() > 0 {

View file

@ -68,7 +68,7 @@ impl LogMessageCollector {
pub fn write_metadata(&mut self, from: &LogFrom, data: &BuildLogStart) -> Result<(), String>{
let metapath = self.path_for_metadata(&from)?;
let mut fp = self.open_file(metapath)?;
let mut fp = self.open_file(&metapath)?;
match serde_json::to_string(data) {
Ok(data) => {
@ -87,7 +87,7 @@ impl LogMessageCollector {
pub fn write_result(&mut self, from: &LogFrom, data: &BuildResult) -> Result<(), String>{
let path = self.path_for_result(&from)?;
let mut fp = self.open_file(path)?;
let mut fp = self.open_file(&path)?;
match serde_json::to_string(data) {
Ok(data) => {
@ -110,7 +110,7 @@ impl LogMessageCollector {
))
} else {
let logpath = self.path_for_log(&from)?;
let fp = self.open_file(logpath)?;
let fp = self.open_file(&logpath)?;
let writer = LineWriter::new(fp);
self.handles.insert(from.clone(), writer);
if let Some(handle) = self.handles.get_mut(&from) {
@ -157,7 +157,7 @@ impl LogMessageCollector {
}
}
fn open_file(&self, path: PathBuf) -> Result<File, String> {
fn open_file(&self, path: &PathBuf) -> Result<File, String> {
let dir = path.parent().unwrap();
fs::create_dir_all(dir).unwrap();
@ -369,12 +369,12 @@ mod tests {
assert!(
worker
.open_file(worker.path_for_log(&make_from("a")).unwrap())
.open_file(&worker.path_for_log(&make_from("a")).unwrap())
.is_ok()
);
assert!(
worker
.open_file(worker.path_for_log(&make_from("b.foo/123")).unwrap())
.open_file(&worker.path_for_log(&make_from("b.foo/123")).unwrap())
.is_ok()
);
}

View file

@ -38,7 +38,7 @@ pub struct MassRebuildWorker<E> {
impl<E: stats::SysEvents> MassRebuildWorker<E> {
pub fn new(
cloner: checkout::CachedCloner,
nix: nix::Nix,
nix: &nix::Nix,
github: hubcaps::Github,
acl: ACL,
identity: String,
@ -71,8 +71,8 @@ impl<E: stats::SysEvents> MassRebuildWorker<E> {
if darwin {
update_labels(
&issue,
vec![String::from("6.topic: darwin")],
vec![],
&vec![String::from("6.topic: darwin")],
&vec![],
);
}
}
@ -86,8 +86,8 @@ impl<E: stats::SysEvents> MassRebuildWorker<E> {
update_labels(
&issue,
tagger.tags_to_add(),
tagger.tags_to_remove(),
&tagger.tags_to_add(),
&tagger.tags_to_remove(),
);
}
}
@ -167,7 +167,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
overall_status.set_with_description("Starting", hubcaps::statuses::State::Pending);
let project = self.cloner.project(
job.repo.full_name.clone(),
&job.repo.full_name,
job.repo.clone_url.clone(),
);
@ -211,7 +211,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
if let Err(mut output) = rebuildsniff.find_before() {
overall_status.set_url(make_gist(
&gists,
"Output path comparison".to_owned(),
"Output path comparison",
Some("".to_owned()),
file_to_str(&mut output),
));
@ -251,7 +251,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
}
let possibly_touched_packages =
parse_commit_messages(co.commit_messages_from_head(&job.pr.head_sha).unwrap_or(
parse_commit_messages(&co.commit_messages_from_head(&job.pr.head_sha).unwrap_or(
vec!["".to_owned()],
));
@ -272,16 +272,16 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
update_labels(
&issue,
vec!["2.status: merge conflict".to_owned()],
vec![],
&vec!["2.status: merge conflict".to_owned()],
&vec![],
);
return self.actions().skip(&job);
} else {
update_labels(
&issue,
vec![],
vec!["2.status: merge conflict".to_owned()],
&vec![],
&vec!["2.status: merge conflict".to_owned()],
);
}
@ -300,7 +300,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
if let Err(mut output) = rebuildsniff.find_after() {
overall_status.set_url(make_gist(
&gists,
"Output path comparison".to_owned(),
"Output path comparison",
Some("".to_owned()),
file_to_str(&mut output),
));
@ -439,7 +439,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
state = hubcaps::statuses::State::Failure;
gist_url = make_gist(
&gists,
check.name(),
&check.name(),
Some(format!("{:?}", state)),
file_to_str(&mut out),
);
@ -511,7 +511,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
state = hubcaps::statuses::State::Failure;
gist_url = make_gist(
&gists,
String::from("Meta Check"),
"Meta Check",
Some(format!("{:?}", state)),
file_to_str(&mut out),
);
@ -534,17 +534,17 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
}
update_labels(
&issue,
stdenvtagger.tags_to_add(),
stdenvtagger.tags_to_remove(),
&stdenvtagger.tags_to_add(),
&stdenvtagger.tags_to_remove(),
);
if let Some((removed, added)) = rebuildsniff.package_diff() {
let mut addremovetagger = PkgsAddedRemovedTagger::new();
addremovetagger.changed(removed, added);
addremovetagger.changed(&removed, &added);
update_labels(
&issue,
addremovetagger.tags_to_add(),
addremovetagger.tags_to_remove(),
&addremovetagger.tags_to_add(),
&addremovetagger.tags_to_remove(),
);
}
@ -553,7 +553,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
if attrs.len() > 0 {
let gist_url = make_gist(
&gists,
String::from("Changed Paths"),
"Changed Paths",
Some("".to_owned()),
attrs
.iter()
@ -570,8 +570,8 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
update_labels(
&issue,
rebuild_tags.tags_to_add(),
rebuild_tags.tags_to_remove(),
&rebuild_tags.tags_to_add(),
&rebuild_tags.tags_to_remove(),
);
overall_status.set_with_description("^.^!", hubcaps::statuses::State::Success);
@ -593,15 +593,15 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
fn make_gist<'a>(
gists: &hubcaps::gists::Gists<'a>,
name: String,
name: &str,
description: Option<String>,
contents: String,
) -> Option<String> {
let mut files = HashMap::new();
let mut files: HashMap<String, hubcaps::gists::Content> = HashMap::new();
files.insert(
name.clone(),
name.to_string(),
hubcaps::gists::Content {
filename: Some(name.clone()),
filename: Some(name.to_string()),
content: contents,
},
);
@ -618,7 +618,7 @@ fn make_gist<'a>(
)
}
pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: Vec<String>, remove: Vec<String>) {
pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: &Vec<String>, remove: &Vec<String>) {
let l = issue.labels();
let existing: Vec<String> = issue
@ -649,7 +649,7 @@ pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: Vec<String>, remove
}
}
fn parse_commit_messages(messages: Vec<String>) -> Vec<String> {
fn parse_commit_messages(messages: &[String]) -> Vec<String> {
messages
.iter()
.filter_map(|line| {
@ -689,7 +689,7 @@ mod tests {
];
assert_eq!(
parse_commit_messages(
"
&"
firefox{-esr,}: fix failing build due to the google-api-key
Merge pull request #34483 from andir/dovecot-cve-2017-15132
firefox: enable official branding
@ -705,7 +705,7 @@ mod tests {
"
.lines()
.map(|l| l.to_owned())
.collect(),
.collect::<Vec<String>>(),
),
expect
);