From patchwork Thu Jun 6 03:17:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1110862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45K9nl20X4z9s9y for ; Thu, 6 Jun 2019 13:17:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45K9nk5L9kzDqbm for ; Thu, 6 Jun 2019 13:17:30 +1000 (AEST) X-Original-To: snowpatch@lists.ozlabs.org Delivered-To: snowpatch@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=ajd@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45K9nf11c7zDqJ5 for ; Thu, 6 Jun 2019 13:17:25 +1000 (AEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x563HElS049951 for ; Wed, 5 Jun 2019 23:17:22 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2sxpd8a4qb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 05 Jun 2019 23:17:21 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Jun 2019 04:17:20 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 6 Jun 2019 04:17:18 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x563HHD059441324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 6 Jun 2019 03:17:17 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 423FB5204F for ; Thu, 6 Jun 2019 03:17:17 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id A3E9A5204E for ; Thu, 6 Jun 2019 03:17:16 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 9EA3CA01BD for ; Thu, 6 Jun 2019 13:17:14 +1000 (AEST) From: Andrew Donnellan To: snowpatch@lists.ozlabs.org Date: Thu, 6 Jun 2019 13:17:05 +1000 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19060603-0008-0000-0000-000002F005E0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060603-0009-0000-0000-0000225CF005 Message-Id: <20190606031705.7801-1-ajd@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-06_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906060022 Subject: [snowpatch] [PATCH] Fix various clippy and fmt issues X-BeenThere: snowpatch@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Continuous Integration for patch-based workflows List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: snowpatch-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "snowpatch" Signed-off-by: Andrew Donnellan --- already applied --- src/git.rs | 3 +-- src/jenkins.rs | 28 +++++++++++++++++----------- src/main.rs | 24 ++++++++++++++++++------ src/patchwork.rs | 7 +++---- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/git.rs b/src/git.rs index d025d0388816..ad4bb781d23b 100644 --- a/src/git.rs +++ b/src/git.rs @@ -68,7 +68,7 @@ pub fn pull(repo: &Repository) -> Result { } } -pub fn checkout_branch(repo: &Repository, branch: &str) -> () { +pub fn checkout_branch(repo: &Repository, branch: &str) { let workdir = repo.workdir().unwrap(); // TODO: support bare repositories // Make sure there's no junk lying around before we switch @@ -107,7 +107,6 @@ pub fn checkout_branch(repo: &Repository, branch: &str) -> () { .current_dir(&workdir) .output() .unwrap(); - () } pub fn apply_patch(repo: &Repository, path: &Path) -> Result { diff --git a/src/jenkins.rs b/src/jenkins.rs index 3cb4f6f9a17b..b367e0db3a7a 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -118,10 +118,13 @@ impl CIBackend for JenkinsBackend { Some(artifact) => { let artifact_url = format!("{}/artifact/{}", build_handle, artifact); match self.get_url(&artifact_url) { - Ok(resp) => match resp.status().is_success() { - true => artifact_url, - false => default_url, - }, + Ok(resp) => { + if resp.status().is_success() { + artifact_url + } else { + default_url + } + } Err(_e) => default_url, } } @@ -137,13 +140,16 @@ impl CIBackend for JenkinsBackend { match job.get("description") { Some(artifact) => { match self.get_url(&format!("{}/artifact/{}", build_handle, artifact)) { - Ok(mut resp) => match resp.status().is_success() { - true => match resp.text() { - Ok(text) => Some(text), - Err(_e) => None, - }, - false => None, - }, + Ok(mut resp) => { + if resp.status().is_success() { + match resp.text() { + Ok(text) => Some(text), + Err(_e) => None, + } + } else { + None + } + } Err(_e) => None, } } diff --git a/src/main.rs b/src/main.rs index ba8c54d792d9..48a09afa2d42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,10 +118,9 @@ fn run_test( } params.push((&job.remote, &project.remote_uri)); params.push((&job.branch, tag)); - match job.base { - Some(ref base_param) => params.push((&base_param, base)), - _ => { } - }; + if let Some(ref base_param) = job.base { + params.push((&base_param, base)); + } info!("Starting job: {}", &job.title); let res = backend @@ -288,7 +287,17 @@ fn test_patch( // We've set up a remote branch, time to kick off tests let test = thread::Builder::new() .name(tag.to_string()) - .spawn(move || run_tests(&settings, client, &project, &tag, &branch_name, &base, hefty_tests)) + .spawn(move || { + run_tests( + &settings, + client, + &project, + &tag, + &branch_name, + &base, + hefty_tests, + ) + }) .unwrap(); results.append(&mut test.join().unwrap()); @@ -311,7 +320,10 @@ fn test_patch( results } -#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] +#[cfg_attr( + feature = "cargo-clippy", + allow(clippy::cyclomatic_complexity, clippy::cognitive_complexity) +)] fn run() -> Result<(), Box> { let mut log_builder = Builder::new(); // By default, log at the "info" level for every module diff --git a/src/patchwork.rs b/src/patchwork.rs index e560b666b00d..46bed953d9a9 100644 --- a/src/patchwork.rs +++ b/src/patchwork.rs @@ -210,8 +210,7 @@ pub struct PatchworkServer { } impl PatchworkServer { - #[cfg_attr(feature = "cargo-clippy", allow(ptr_arg))] - pub fn new(url: &String, client: &std::sync::Arc) -> PatchworkServer { + pub fn new(url: &str, client: &std::sync::Arc) -> PatchworkServer { let mut headers = HeaderMap::new(); // These .parse().unwrap() blocks are making sure it's a valid ASCII // header value. They don't need to be refactored and hopefully in @@ -219,13 +218,13 @@ impl PatchworkServer { headers.insert(ACCEPT, "application/json".parse().unwrap()); headers.insert(CONTENT_TYPE, "application/json".parse().unwrap()); PatchworkServer { - url: url.clone(), + url: url.to_string(), client: client.clone(), headers, } } - #[cfg_attr(feature = "cargo-clippy", allow(ptr_arg))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::ptr_arg))] pub fn set_authentication( &mut self, username: &Option,