Skip to content

Commit 9f694f1

Browse files
fix: resolve Clippy issues (#151)
1 parent a4008c4 commit 9f694f1

6 files changed

Lines changed: 4 additions & 454 deletions

File tree

packages/core/shield/src/action.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -91,47 +91,3 @@ macro_rules! erased_action {
9191
}
9292
};
9393
}
94-
95-
#[cfg(test)]
96-
pub(crate) mod tests {
97-
use async_trait::async_trait;
98-
99-
use crate::{
100-
error::ShieldError, form::Form, provider::tests::TestProvider, request::Request,
101-
response::Response, session::Session,
102-
};
103-
104-
use super::Action;
105-
106-
pub const TEST_ACTION_ID: &str = "test";
107-
pub const TEST_ACTION_NAME: &str = "Test";
108-
109-
#[derive(Default)]
110-
pub struct TestAction {}
111-
112-
#[async_trait]
113-
impl Action<TestProvider> for TestAction {
114-
fn id(&self) -> String {
115-
TEST_ACTION_ID.to_owned()
116-
}
117-
118-
fn name(&self) -> String {
119-
TEST_ACTION_NAME.to_owned()
120-
}
121-
122-
fn form(&self, _provider: TestProvider) -> Form {
123-
Form { inputs: vec![] }
124-
}
125-
126-
async fn call(
127-
&self,
128-
_provider: TestProvider,
129-
_session: Session,
130-
_request: Request,
131-
) -> Result<Response, ShieldError> {
132-
Ok(Response::Default)
133-
}
134-
}
135-
136-
erased_action!(TestAction);
137-
}

packages/core/shield/src/method.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -90,48 +90,3 @@ macro_rules! erased_method {
9090
}
9191
};
9292
}
93-
94-
#[cfg(test)]
95-
pub(crate) mod tests {
96-
use async_trait::async_trait;
97-
98-
use crate::{
99-
action::{Action, tests::TestAction},
100-
error::ShieldError,
101-
provider::tests::TestProvider,
102-
};
103-
104-
use super::Method;
105-
106-
pub const TEST_METHOD_ID: &str = "test";
107-
108-
#[derive(Default)]
109-
pub struct TestMethod {
110-
id: Option<&'static str>,
111-
}
112-
113-
impl TestMethod {
114-
// TODO
115-
pub fn _with_id(mut self, id: &'static str) -> Self {
116-
self.id = Some(id);
117-
self
118-
}
119-
}
120-
121-
#[async_trait]
122-
impl Method<TestProvider> for TestMethod {
123-
fn id(&self) -> String {
124-
self.id.unwrap_or(TEST_METHOD_ID).to_owned()
125-
}
126-
127-
fn actions(&self) -> Vec<Box<dyn Action<TestProvider>>> {
128-
vec![Box::new(TestAction::default())]
129-
}
130-
131-
async fn providers(&self) -> Result<Vec<TestProvider>, ShieldError> {
132-
Ok(vec![TestProvider::default()])
133-
}
134-
}
135-
136-
erased_method!(TestMethod);
137-
}

packages/core/shield/src/provider.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,3 @@ pub trait Provider: Send + Sync {
55

66
fn name(&self) -> String;
77
}
8-
9-
#[cfg(test)]
10-
pub(crate) mod tests {
11-
use async_trait::async_trait;
12-
13-
use crate::method::tests::TEST_METHOD_ID;
14-
15-
use super::Provider;
16-
17-
pub const TEST_PROVIDER_NAME: &str = "Test";
18-
19-
#[derive(Default)]
20-
pub struct TestProvider {}
21-
22-
#[async_trait]
23-
impl Provider for TestProvider {
24-
fn method_id(&self) -> String {
25-
TEST_METHOD_ID.to_owned()
26-
}
27-
28-
fn id(&self) -> Option<String> {
29-
None
30-
}
31-
32-
fn name(&self) -> String {
33-
TEST_PROVIDER_NAME.to_owned()
34-
}
35-
}
36-
}

packages/core/shield/src/shield.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ impl<U: User> Shield<U> {
7979
};
8080

8181
let name = action.erased_name();
82-
if let Some(action_name) = &action_name {
83-
if *action_name != name {
84-
warn!("Action name mismatch `{}` != `{}`", action_name, name);
85-
}
82+
if let Some(action_name) = &action_name
83+
&& *action_name != name
84+
{
85+
warn!("Action name mismatch `{}` != `{}`", action_name, name);
8686
}
8787
action_name = Some(name);
8888

0 commit comments

Comments
 (0)