Forráskód Böngészése

apply clippy suggestions

Pietro Albini 6 éve
szülő
commit
8c91b9330a
6 módosított fájl, 13 hozzáadás és 11 törlés
  1. 3 2
      parser/src/command.rs
  2. 1 1
      parser/src/token.rs
  3. 4 4
      src/github.rs
  4. 1 1
      src/interactions.rs
  5. 2 1
      src/main.rs
  6. 2 2
      src/payload.rs

+ 3 - 2
parser/src/command.rs

@@ -28,7 +28,7 @@ impl<'a> Input<'a> {
             all: input,
             parsed: 0,
             code: ColorCodeBlocks::new(input),
-            bot: bot,
+            bot,
         }
     }
 
@@ -70,9 +70,10 @@ impl<'a> Input<'a> {
             );
         }
 
-        if let Some(_) = self
+        if self
             .code
             .overlaps_code((self.parsed)..(self.parsed + tok.position()))
+            .is_some()
         {
             return Command::None;
         }

+ 1 - 1
parser/src/token.rs

@@ -72,7 +72,7 @@ impl<'a> Error<'a> {
 impl<'a> Tokenizer<'a> {
     pub fn new(input: &'a str) -> Tokenizer<'a> {
         Tokenizer {
-            input: input,
+            input,
             chars: input.char_indices().peekable(),
         }
     }

+ 4 - 4
src/github.rs

@@ -1,7 +1,6 @@
 use failure::{Error, ResultExt};
 use reqwest::header::{AUTHORIZATION, USER_AGENT};
-use reqwest::Error as HttpError;
-use reqwest::{Client, RequestBuilder, Response};
+use reqwest::{Client, Error as HttpError, RequestBuilder, Response};
 
 #[derive(Debug, serde::Deserialize)]
 pub struct User {
@@ -22,7 +21,7 @@ impl User {
         let permission: rust_team_data::v1::Teams = client
             .get(&url)
             .send()
-            .and_then(|r| r.error_for_status())
+            .and_then(Response::error_for_status)
             .and_then(|mut r| r.json())
             .context("could not get team data")?;
         let map = permission.teams;
@@ -37,6 +36,7 @@ pub struct Label {
 
 impl Label {
     fn exists(&self, repo_api_prefix: &str, client: &GithubClient) -> bool {
+        #[allow(clippy::redundant_pattern_matching)]
         match client
             .get(&format!("{}/labels/{}", repo_api_prefix, self.name))
             .send_req()
@@ -75,7 +75,7 @@ impl Issue {
         }
         client
             .post(&self.comments_url)
-            .json(&PostComment { body: body })
+            .json(&PostComment { body })
             .send_req()
             .context("failed to post comment")?;
         Ok(())

+ 1 - 1
src/interactions.rs

@@ -21,7 +21,7 @@ impl<'a> ErrorComment<'a> {
     pub fn post(&self, client: &GithubClient) -> Result<(), Error> {
         let mut body = String::new();
         writeln!(body, "**Error**: {}", self.message)?;
-        writeln!(body, "")?;
+        writeln!(body)?;
         writeln!(
             body,
             "Please let **`@rust-lang/release`** know if you're having trouble with this bot."

+ 2 - 1
src/main.rs

@@ -1,4 +1,5 @@
 #![feature(proc_macro_hygiene, decl_macro)]
+#![allow(clippy::new_without_default)]
 
 #[macro_use]
 extern crate rocket;
@@ -49,7 +50,7 @@ impl<'a, 'r> request::FromRequest<'a, 'r> for Event {
         let ev = if let Some(ev) = req.headers().get_one("X-GitHub-Event") {
             ev
         } else {
-            return Outcome::Failure((Status::BadRequest, format!("Needs a X-GitHub-Event")));
+            return Outcome::Failure((Status::BadRequest, "Needs a X-GitHub-Event".into()));
         };
         let ev = match ev {
             "issue_comment" => Event::IssueComment,

+ 2 - 2
src/payload.rs

@@ -19,7 +19,7 @@ impl FromDataSimple for SignedPayload {
             None => {
                 return Outcome::Failure((
                     Status::Unauthorized,
-                    format!("Unauthorized, no signature"),
+                    "Unauthorized, no signature".into(),
                 ));
             }
         };
@@ -52,7 +52,7 @@ impl FromDataSimple for SignedPayload {
         let hmac = signer.sign_to_vec().unwrap();
 
         if !memcmp::eq(&hmac, &signature) {
-            return Outcome::Failure((Status::Unauthorized, format!("HMAC not correct")));
+            return Outcome::Failure((Status::Unauthorized, "HMAC not correct".into()));
         }
 
         Outcome::Success(SignedPayload(buf))