Enable more lints
This commit is contained in:
parent
3f73578fc9
commit
da0e5f7373
12 changed files with 17 additions and 12 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![warn(clippy::all, clippy::restriction, clippy::pedantic, clippy::cargo)]
|
||||||
|
|
||||||
mod diffs;
|
mod diffs;
|
||||||
mod operation_transformation;
|
mod operation_transformation;
|
||||||
mod tokenizer;
|
mod tokenizer;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![warn(clippy::all, clippy::restriction, clippy::pedantic, clippy::cargo)]
|
||||||
|
|
||||||
use core::str;
|
use core::str;
|
||||||
|
|
||||||
use base64::{engine::general_purpose::STANDARD_NO_PAD, Engine as _};
|
use base64::{engine::general_purpose::STANDARD_NO_PAD, Engine as _};
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ impl Config {
|
||||||
);
|
);
|
||||||
Self::load_from_file(path).await
|
Self::load_from_file(path).await
|
||||||
} else {
|
} else {
|
||||||
let config = Config::default();
|
let config = Self::default();
|
||||||
config.write(path).await?;
|
config.write(path).await?;
|
||||||
warn!(
|
warn!(
|
||||||
"Configuration file not found, wrote default configuration to {:?}",
|
"Configuration file not found, wrote default configuration to {:?}",
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ pub struct DatabaseConfig {
|
||||||
|
|
||||||
fn default_sqlite_url() -> String {
|
fn default_sqlite_url() -> String {
|
||||||
debug!("Using default sqlite url: {}", DEFAULT_SQLITE_URL);
|
debug!("Using default sqlite url: {}", DEFAULT_SQLITE_URL);
|
||||||
DEFAULT_SQLITE_URL.to_string()
|
DEFAULT_SQLITE_URL.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_max_connections() -> u32 {
|
fn default_max_connections() -> u32 {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ pub struct ServerConfig {
|
||||||
|
|
||||||
fn default_host() -> String {
|
fn default_host() -> String {
|
||||||
debug!("Using default server host: {}", DEFAULT_HOST);
|
debug!("Using default server host: {}", DEFAULT_HOST);
|
||||||
DEFAULT_HOST.to_string()
|
DEFAULT_HOST.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_port() -> u16 {
|
fn default_port() -> u16 {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct User {
|
||||||
|
|
||||||
impl Default for UserConfig {
|
impl Default for UserConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
UserConfig {
|
Self {
|
||||||
user_tokens: default_users(),
|
user_tokens: default_users(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ impl Default for UserConfig {
|
||||||
|
|
||||||
fn default_users() -> Vec<User> {
|
fn default_users() -> Vec<User> {
|
||||||
vec![User {
|
vec![User {
|
||||||
name: "admin".to_string(),
|
name: "admin".to_owned(),
|
||||||
token: get_random_token(),
|
token: get_random_token(),
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{str::FromStr, time::Duration};
|
use core::{str::FromStr, time::Duration};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use models::{
|
use models::{
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ pub struct StoredDocumentVersion {
|
||||||
pub is_deleted: bool,
|
pub is_deleted: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq<StoredDocumentVersion> for StoredDocumentVersion {
|
impl PartialEq<Self> for StoredDocumentVersion {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.vault_id == other.vault_id && self.vault_update_id == other.vault_update_id
|
self.vault_id == other.vault_id && self.vault_update_id == other.vault_update_id
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ impl OperationOutput for SyncServerError {
|
||||||
type Inner = Self;
|
type Inner = Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_error(error: anyhow::Error) -> SyncServerError { SyncServerError::InitError(error) }
|
pub const fn init_error(error: anyhow::Error) -> SyncServerError { SyncServerError::InitError(error) }
|
||||||
|
|
||||||
pub fn server_error(error: anyhow::Error) -> SyncServerError {
|
pub fn server_error(error: anyhow::Error) -> SyncServerError {
|
||||||
warn!("Server error: {:?}", error);
|
warn!("Server error: {:?}", error);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![warn(clippy::all, clippy::restriction, clippy::pedantic, clippy::cargo)]
|
||||||
|
|
||||||
mod app_state;
|
mod app_state;
|
||||||
mod config;
|
mod config;
|
||||||
mod consts;
|
mod consts;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ pub async fn create_server(app_state: AppState) -> Result<()> {
|
||||||
|
|
||||||
let mut api = OpenApi {
|
let mut api = OpenApi {
|
||||||
info: Info {
|
info: Info {
|
||||||
description: Some("an example API".to_string()),
|
description: Some("an example API".to_owned()),
|
||||||
..Info::default()
|
..Info::default()
|
||||||
},
|
},
|
||||||
..OpenApi::default()
|
..OpenApi::default()
|
||||||
|
|
@ -82,7 +82,7 @@ pub async fn create_server(app_state: AppState) -> Result<()> {
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(address.clone())
|
let listener = tokio::net::TcpListener::bind(address.clone())
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("Failed to bind to address: {}", address))?;
|
.with_context(|| format!("Failed to bind to address: {address}"))?;
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Listening on http://{}",
|
"Listening on http://{}",
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ pub async fn ping(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
) -> Result<Json<PingResponse>, SyncServerError> {
|
) -> Result<Json<PingResponse>, SyncServerError> {
|
||||||
let is_authenticated = maybe_auth_header
|
let is_authenticated = maybe_auth_header
|
||||||
.map(|auth_header| auth(&state, auth_header.token()).is_ok())
|
.is_some_and(|auth_header| auth(&state, auth_header.token()).is_ok());
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
Ok(Json(PingResponse {
|
Ok(Json(PingResponse {
|
||||||
server_version: env!("CARGO_PKG_VERSION").to_string(),
|
server_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue