Skip to content

Commit

Permalink
Cargo clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
syl20bnr committed Feb 9, 2024
1 parent 8e41d3a commit a7dec88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
8 changes: 4 additions & 4 deletions backend-comparison/src/burnbenchapp/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::{
path::{Path, PathBuf},
};

pub(crate) static CLIENT_ID: &'static str = "Iv1.84002254a02791f3";
static GITHUB_API_VERSION_HEADER: &'static str = "X-GitHub-Api-Version";
static GITHUB_API_VERSION: &'static str = "2022-11-28";
pub(crate) static CLIENT_ID: &str = "Iv1.84002254a02791f3";
static GITHUB_API_VERSION_HEADER: &str = "X-GitHub-Api-Version";
static GITHUB_API_VERSION: &str = "2022-11-28";

/// Return the file path for the auth cache on disk
pub fn get_auth_cache_file_path() -> PathBuf {
Expand Down Expand Up @@ -68,7 +68,7 @@ pub(crate) fn save_token(token: &str) {
/// Return the token saved in the cache file
pub(crate) fn get_token_from_cache() -> Option<String> {
let path = get_auth_cache_file_path();
match fs::read_to_string(&path) {
match fs::read_to_string(path) {
Ok(contents) => contents.lines().next().map(str::to_string),
_ => None,
}
Expand Down
14 changes: 6 additions & 8 deletions backend-comparison/src/burnbenchapp/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn execute() {
/// Create an access token from GitHub Burnbench application and store it
/// to be used with the user benchmark backend.
fn command_auth() {
let mut flow = match DeviceFlow::start(&CLIENT_ID, None) {
let mut flow = match DeviceFlow::start(CLIENT_ID, None) {
Ok(flow) => flow,
Err(e) => {
eprintln!("Error authenticating: {}", e);
Expand All @@ -122,12 +122,10 @@ fn command_auth() {
println!("\n {}\n", flow.verification_uri.clone().unwrap());
let user_code = flow.user_code.clone().unwrap();
println!("👉 And enter code: {}", &user_code);
match Clipboard::new() {
Ok(mut clipboard) => match clipboard.set_text(user_code) {
Ok(_) => println!("📋 Code has been successfully copied to clipboard."),
Err(_) => (),
},
Err(_) => (),
if let Ok(mut clipboard) = Clipboard::new() {
if clipboard.set_text(user_code).is_ok() {
println!("📋 Code has been successfully copied to clipboard.")
};
};
thread::sleep(FIVE_SECONDS);
match flow.poll(20) {
Expand All @@ -153,7 +151,7 @@ fn command_run(run_args: RunArgs) {
if run_args.share {
// Verify if a token is saved
let token = get_token_from_cache();
if let None = token {
if token.is_none() {
eprintln!("You need to be authenticated to be able to share benchmark results.");
eprintln!("Run the command 'burnbench auth' to authenticate.");
return;
Expand Down

0 comments on commit a7dec88

Please sign in to comment.