Clippy: comparisons of array len to 0

This commit is contained in:
Graham Christensen 2019-01-02 17:34:39 -05:00
parent 848f1a0952
commit 99159dd74e
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
8 changed files with 15 additions and 15 deletions

View file

@ -166,7 +166,7 @@ impl AsyncCmd {
}
}
if waiters.len() == 0 {
if waiters.is_empty() {
debug!("Closing up the waiter receiver thread, no more waiters.");
break;
}

View file

@ -8,7 +8,7 @@ pub fn parse(text: &str) -> Option<Vec<Instruction>> {
})
.collect();
if instructions.len() == 0 {
if instructions.is_empty() {
None
} else {
Some(instructions)

View file

@ -78,11 +78,11 @@ impl PkgsAddedRemovedTagger {
}
pub fn changed(&mut self, removed: &[PackageArch], added: &[PackageArch]) {
if removed.len() > 0 {
if !removed.is_empty() {
self.selected.push(String::from("8.has: clean-up"));
}
if added.len() > 0 {
if !added.is_empty() {
self.selected.push(String::from("8.has: package (new)"));
}
}

View file

@ -295,7 +295,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
) {
let mut actions = self.actions(&job, notifier);
if job.attrs.len() == 0 {
if job.attrs.is_empty() {
actions.nothing_to_do();
return;
}
@ -360,7 +360,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
actions.log_started(can_build.clone(), cannot_build_attrs.clone());
actions.log_instantiation_errors(cannot_build);
if can_build.len() == 0 {
if can_build.is_empty() {
actions.build_not_attempted(cannot_build_attrs);
return;
}

View file

@ -51,7 +51,7 @@ impl Stdenvs {
}
pub fn are_same(&self) -> bool {
self.changed().len() == 0
self.changed().is_empty()
}
pub fn changed(&self) -> Vec<System> {

View file

@ -64,7 +64,7 @@ impl worker::SimpleWorker for GitHubCommentWorker {
&job.repository.full_name,
);
if build_destinations.len() == 0 {
if build_destinations.is_empty() {
println!("No build destinations for: {:?}", job);
// Don't process comments if they can't build anything
return vec![worker::Action::Ack];

View file

@ -85,7 +85,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime<Utc>) -> Chec
.collect();
all_attrs.sort();
if all_attrs.len() == 0{
if all_attrs.is_empty() {
all_attrs = vec![String::from("(unknown attributes)")];
}
@ -117,7 +117,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime<Utc>) -> Chec
let text: String;
if result.output.len() > 0 {
if !result.output.is_empty() {
let mut reply: Vec<String> = vec![];
reply.push("## Partial log".to_owned());
@ -166,7 +166,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime<Utc>) -> Chec
fn result_to_comment(result: &LegacyBuildResult) -> String {
let mut reply: Vec<String> = vec![];
let log_link = if result.output.len() > 0 {
let log_link = if !result.output.is_empty() {
format!(
" [(full log)](https://logs.nix.ci/?key={}/{}.{}&attempt_id={})",
&result.repo.owner.to_lowercase(),
@ -205,7 +205,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String {
&skipped));
}
if result.output.len() > 0 {
if !result.output.is_empty() {
reply.extend(partial_log_segment(result.output.clone()));
reply.push("".to_owned());
reply.push("".to_owned());
@ -220,7 +220,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String {
fn list_segment(name: &str, things: &[String]) -> Vec<String> {
let mut reply: Vec<String> = vec![];
if things.len() > 0 {
if !things.is_empty() {
reply.push(format!("{}: {}", name, things.join(", ")));
reply.push("".to_owned());
}

View file

@ -487,7 +487,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
try_build.sort();
try_build.dedup();
if try_build.len() > 0 && try_build.len() <= 10 {
if !try_build.is_empty() && try_build.len() <= 10 {
// In the case of trying to merge master in to
// a stable branch, we don't want to do this.
// Therefore, only schedule builds if there
@ -550,7 +550,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
let mut rebuild_tags = RebuildTagger::new();
if let Some(attrs) = rebuildsniff.calculate_rebuild() {
if attrs.len() > 0 {
if !attrs.is_empty() {
let gist_url = make_gist(
&gists,
"Changed Paths",