diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2023-01-01 20:47:59 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2023-01-01 20:50:11 -0500 |
commit | 33dfcd18252dd8a4845cd58b93bd177ab0dffde9 (patch) | |
tree | fbb6fc049677a492cd9d5196d6b1709f0b32b873 | |
parent | d3fbefad9cf25786fb5f28f96eeceb65d0a8b35b (diff) |
Fix clippy warnings
-rw-r--r-- | protocol/src/bridge_engine.rs | 2 | ||||
-rw-r--r-- | server/src/auth.rs | 8 | ||||
-rw-r--r-- | server/src/error.rs | 6 | ||||
-rw-r--r-- | server/src/fake_auth.rs | 6 | ||||
-rw-r--r-- | server/src/play.rs | 5 | ||||
-rw-r--r-- | server/tests/common/mod.rs | 2 | ||||
-rw-r--r-- | webapp/src/components/app_context_provider.rs | 2 | ||||
-rw-r--r-- | webapp/src/components/bidding.rs | 4 | ||||
-rw-r--r-- | webapp/src/components/card.rs | 2 | ||||
-rw-r--r-- | webapp/src/components/hand.rs | 4 | ||||
-rw-r--r-- | webapp/src/components/table.rs | 8 | ||||
-rw-r--r-- | webapp/src/components/trick_in_play.rs | 2 | ||||
-rw-r--r-- | webapp/src/main.rs | 4 |
13 files changed, 32 insertions, 23 deletions
diff --git a/protocol/src/bridge_engine.rs b/protocol/src/bridge_engine.rs index 74a8262..73a8bf4 100644 --- a/protocol/src/bridge_engine.rs +++ b/protocol/src/bridge_engine.rs @@ -517,7 +517,7 @@ impl GameState { MoveResult::Current(play_state) => { MoveResult::Current(play_state.into()) } - MoveResult::Next(result) => MoveResult::Next(result.into()), + MoveResult::Next(result) => MoveResult::Next(result), }) } } diff --git a/server/src/auth.rs b/server/src/auth.rs index 76b16cf..173a2b3 100644 --- a/server/src/auth.rs +++ b/server/src/auth.rs @@ -96,6 +96,12 @@ impl SessionId { } } +impl Default for SessionId { + fn default() -> Self { + Self::new() + } +} + impl ToString for SessionId { fn to_string(&self) -> String { self.0.to_string() @@ -116,7 +122,7 @@ fn token_safe_time() -> chrono::Duration { chrono::Duration::seconds(30) } -pub const LOGIN_CALLBACK: &'static str = "/api/login_callback"; +pub const LOGIN_CALLBACK: &str = "/api/login_callback"; fn redirect_url(app_url: &str) -> RedirectUrl { RedirectUrl::new(format!("{}{}", app_url, LOGIN_CALLBACK)).unwrap() } diff --git a/server/src/error.rs b/server/src/error.rs index 7eb5fa2..ebe1d93 100644 --- a/server/src/error.rs +++ b/server/src/error.rs @@ -70,12 +70,12 @@ impl BridgeError { pub fn as_rejection(&self) -> (http::StatusCode, String) { match self { BridgeError::NotLoggedIn => { - (StatusCode::UNAUTHORIZED, format!("Must be logged in")) + (StatusCode::UNAUTHORIZED, "Must be logged in".to_string()) } BridgeError::OpenidRequestTokenError(_) => { - (StatusCode::UNAUTHORIZED, format!("Error fetching token")) + (StatusCode::UNAUTHORIZED, "Error fetching token".to_string()) } - _ => (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")), + _ => (StatusCode::INTERNAL_SERVER_ERROR, "Error: {self}".to_string()), } } } diff --git a/server/src/fake_auth.rs b/server/src/fake_auth.rs index 6a3ff2c..caea745 100644 --- a/server/src/fake_auth.rs +++ b/server/src/fake_auth.rs @@ -29,6 +29,12 @@ impl FakeAuthenticator { } } +impl Default for FakeAuthenticator { + fn default() -> Self { + Self::new() + } +} + #[async_trait] impl Authenticator for FakeAuthenticator { async fn user_info( diff --git a/server/src/play.rs b/server/src/play.rs index 893cb95..f413a74 100644 --- a/server/src/play.rs +++ b/server/src/play.rs @@ -141,10 +141,7 @@ impl<J: Journal<TableUpdate>> Table<J> { } pub fn game_in_progress(&self) -> bool { - match &self.state { - TableState::Game(_) => true, - _ => false, - } + matches!(&self.state, TableState::Game(_)) } pub fn game(&self) -> Result<&GameState, BridgeError> { diff --git a/server/tests/common/mod.rs b/server/tests/common/mod.rs index e907306..f88a970 100644 --- a/server/tests/common/mod.rs +++ b/server/tests/common/mod.rs @@ -12,10 +12,12 @@ pub fn test_setup() { .try_init(); } +#[allow(dead_code)] // Only used in ignored tests. pub struct TestDb { db_pool: PgPool, } +#[allow(dead_code)] // Only used in ignored tests. impl TestDb { pub async fn new() -> Self { test_setup(); diff --git a/webapp/src/components/app_context_provider.rs b/webapp/src/components/app_context_provider.rs index 081026c..35b35d7 100644 --- a/webapp/src/components/app_context_provider.rs +++ b/webapp/src/components/app_context_provider.rs @@ -113,7 +113,7 @@ async fn initialize_user_info() -> Result<Option<UserInfo>, anyhow::Error> { .assign("/api/login") .unwrap(); }; - Ok(ok_json(response).await.context("requesting user_info")?) + ok_json(response).await.context("requesting user_info") } pub fn use_app_context() -> AppContext { diff --git a/webapp/src/components/bidding.rs b/webapp/src/components/bidding.rs index cce854b..e5950f6 100644 --- a/webapp/src/components/bidding.rs +++ b/webapp/src/components/bidding.rs @@ -15,7 +15,7 @@ pub fn bidding(props: &BiddingProperties) -> Html { { let bidding = bidding.clone(); - let dealer = props.dealer.clone(); + let dealer = props.dealer; use_effect_with_deps( move |_| { bidding.set(bridge_engine::Bidding::new(dealer)); @@ -45,7 +45,7 @@ pub fn bidding(props: &BiddingProperties) -> Html { <> <p>{ "Bidding box" }</p> <BiddingBox - current_bid={ bidding.highest_bid().clone() } + current_bid={ bidding.highest_bid() } { on_bid } /> <p>{ "Bidding table" }</p> diff --git a/webapp/src/components/card.rs b/webapp/src/components/card.rs index cf42923..6323572 100644 --- a/webapp/src/components/card.rs +++ b/webapp/src/components/card.rs @@ -6,7 +6,7 @@ pub fn ccard(props: &CardProps) -> Html { let card::Card(suit, rank) = props.card; let onclick = { - let card = props.card.clone(); + let card = props.card; let onclick = props.onclick.clone(); Callback::from(move |_| onclick.emit(card)) }; diff --git a/webapp/src/components/hand.rs b/webapp/src/components/hand.rs index d70adfc..6bd8fce 100644 --- a/webapp/src/components/hand.rs +++ b/webapp/src/components/hand.rs @@ -1,5 +1,5 @@ use crate::components::card::Card; -use protocol::{card::{self, sort_cards, RankOrder}, bridge_engine::SUIT_DISPLAY_ORDER}; +use protocol::{card::{sort_cards, RankOrder}, bridge_engine::SUIT_DISPLAY_ORDER}; use yew::prelude::*; use crate::components::HandProps; @@ -10,7 +10,7 @@ pub fn hand(props: &HandProps) -> Html { sort_cards(&SUIT_DISPLAY_ORDER, RankOrder::Descending, &mut cards); let cards = cards.iter().map(|card| { html! { - <Card card={ card.clone() } onclick={ props.on_card_clicked.clone() } /> + <Card card={*card} onclick={ props.on_card_clicked.clone() } /> } }); diff --git a/webapp/src/components/table.rs b/webapp/src/components/table.rs index c1b4b47..9f2cbb3 100644 --- a/webapp/src/components/table.rs +++ b/webapp/src/components/table.rs @@ -82,7 +82,7 @@ impl OnlineTableInner { <div class="sidebar"> <div> <h2>{"Contract"}</h2> - <p>{format!("todo")}</p> + <p>{"todo"}</p> </div> <div> <h2>{"Bidding"}</h2> @@ -90,7 +90,7 @@ impl OnlineTableInner { </div> <div> <h2>{"Trick Count"}</h2> - <p>{format!("todo")}</p> + <p>{"todo"}</p> </div> </div> <div class="center"> @@ -222,7 +222,7 @@ impl Component for OnlineTableInner { fn view(&self, ctx: &yew::Context<Self>) -> Html { match &self.table_state { - None => return loading(), + None => loading(), Some(TableStatePlayerView::Unknown) => html! { <p>{"An error occurred."}</p> }, @@ -250,7 +250,7 @@ pub fn bidding_view( </div> <div class="center"> <BiddingTable bidding={bidding.bidding.clone()} /> - <BiddingBox current_bid={bidding.bidding.highest_bid().clone()} on_bid={ on_bid } /> + <BiddingBox current_bid={bidding.bidding.highest_bid()} on_bid={ on_bid } /> { format!("It is {:?} to bid", bidding.bidding.current_bidder()) } </div> <div class="hand south"> diff --git a/webapp/src/components/trick_in_play.rs b/webapp/src/components/trick_in_play.rs index 883a3c1..e5790a3 100644 --- a/webapp/src/components/trick_in_play.rs +++ b/webapp/src/components/trick_in_play.rs @@ -20,7 +20,7 @@ pub fn trick_in_play(props: &TrickInPlayProps) -> Html { }; html! { <div class={class}> - <Card card={ card.clone() } /> + <Card card={*card} /> </div> } }); diff --git a/webapp/src/main.rs b/webapp/src/main.rs index c907183..1d291ec 100644 --- a/webapp/src/main.rs +++ b/webapp/src/main.rs @@ -1,5 +1,4 @@ -#[allow(unused_imports)] -use log::{debug, error, info, warn}; +#![allow(clippy::let_unit_value)] // This is triggering on yew html! {}. use yew::prelude::*; use yew_router::prelude::*; pub mod components; @@ -50,7 +49,6 @@ fn home() -> Html { } let create_table = { - let ctx = ctx.clone(); Callback::from(move |_| { ctx.create_table(); }) |