Fix linting issues in main February 2024 (#3595)

This commit is contained in:
Przemyslaw Hugh Kaznowski 2024-03-01 12:51:32 +00:00 committed by GitHub
parent a182908fde
commit 2914641827
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 36 additions and 50 deletions

View file

@ -11,7 +11,6 @@ pub mod midhinge;
pub mod mode; pub mod mode;
pub mod nearestrank; pub mod nearestrank;
pub mod percentile; pub mod percentile;
pub mod quartile;
pub mod spread; pub mod spread;
pub mod top; pub mod top;
pub mod trimean; pub mod trimean;

View file

@ -1,19 +0,0 @@
use super::percentile::Percentile;
use crate::sql::number::{Number, Sorted};
pub trait Quartile {
/// Divides the set of numbers into Q_0 (min), Q_1, Q_2, Q_3, and Q_4 (max)
fn quartile(self) -> (f64, f64, f64, f64, f64);
}
impl Quartile for Sorted<&Vec<Number>> {
fn quartile(self) -> (f64, f64, f64, f64, f64) {
(
self.percentile(Number::from(0)),
self.percentile(Number::from(25)),
self.percentile(Number::from(50)),
self.percentile(Number::from(75)),
self.percentile(Number::from(100)),
)
}
}

View file

@ -25,6 +25,7 @@ use crate::idx::{IndexKeyBase, VersionedSerdeState};
use crate::kvs::{Key, Transaction, TransactionType, Val}; use crate::kvs::{Key, Transaction, TransactionType, Val};
use crate::sql::index::{Distance, MTreeParams, VectorType}; use crate::sql::index::{Distance, MTreeParams, VectorType};
use crate::sql::{Array, Object, Thing, Value}; use crate::sql::{Array, Object, Thing, Value};
pub(crate) struct MTreeIndex { pub(crate) struct MTreeIndex {
state_key: Key, state_key: Key,
dim: usize, dim: usize,
@ -491,7 +492,7 @@ impl MTree {
} }
#[cfg_attr(not(target_arch = "wasm32"), async_recursion)] #[cfg_attr(not(target_arch = "wasm32"), async_recursion)]
#[cfg_attr(target_arch = "wasm32", async_recursion(?Send))] #[cfg_attr(target_arch = "wasm32", async_recursion(? Send))]
async fn insert_at_node( async fn insert_at_node(
&mut self, &mut self,
tx: &mut Transaction, tx: &mut Transaction,
@ -876,7 +877,7 @@ impl MTree {
} }
#[cfg_attr(not(target_arch = "wasm32"), async_recursion)] #[cfg_attr(not(target_arch = "wasm32"), async_recursion)]
#[cfg_attr(target_arch = "wasm32", async_recursion(?Send))] #[cfg_attr(target_arch = "wasm32", async_recursion(? Send))]
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
async fn delete_at_node( async fn delete_at_node(
&mut self, &mut self,
@ -1406,7 +1407,9 @@ impl Display for MTreeNode {
} }
} }
} }
trait NodeVectors: Sized { trait NodeVectors: Sized {
#[allow(dead_code)]
fn len(&self) -> usize; fn len(&self) -> usize;
fn get_objects(&self) -> Vec<SharedVector>; fn get_objects(&self) -> Vec<SharedVector>;

View file

@ -289,6 +289,7 @@ impl Complement<Array> for Array {
// ------------------------------ // ------------------------------
#[cfg_attr(feature = "sql2", allow(dead_code))]
pub(crate) trait Concat<T> { pub(crate) trait Concat<T> {
fn concat(self, other: T) -> T; fn concat(self, other: T) -> T;
} }
@ -300,6 +301,12 @@ impl Concat<Array> for Array {
} }
} }
impl Concat<String> for String {
fn concat(self, other: String) -> String {
self + &other
}
}
// ------------------------------ // ------------------------------
pub(crate) trait Difference<T> { pub(crate) trait Difference<T> {

View file

@ -126,22 +126,22 @@ impl Expression {
let l = l.compute(ctx, opt, txn, doc).await?; let l = l.compute(ctx, opt, txn, doc).await?;
match o { match o {
Operator::Or => { Operator::Or => {
if let true = l.is_truthy() { if l.is_truthy() {
return Ok(l); return Ok(l);
} }
} }
Operator::And => { Operator::And => {
if let false = l.is_truthy() { if !l.is_truthy() {
return Ok(l); return Ok(l);
} }
} }
Operator::Tco => { Operator::Tco => {
if let true = l.is_truthy() { if l.is_truthy() {
return Ok(l); return Ok(l);
} }
} }
Operator::Nco => { Operator::Nco => {
if let true = l.is_some() { if l.is_some() {
return Ok(l); return Ok(l);
} }
} }

View file

@ -153,11 +153,11 @@ thread_local! {
// `thread_local!` so all accesses can use `Ordering::Relaxed`. // `thread_local!` so all accesses can use `Ordering::Relaxed`.
/// Whether pretty-printing. /// Whether pretty-printing.
static PRETTY: AtomicBool = AtomicBool::new(false); static PRETTY: AtomicBool = const {AtomicBool::new(false)};
/// The current level of indentation, in units of tabs. /// The current level of indentation, in units of tabs.
static INDENT: AtomicU32 = AtomicU32::new(0); static INDENT: AtomicU32 = const{AtomicU32::new(0)};
/// Whether the next formatting action should be preceded by a newline and indentation. /// Whether the next formatting action should be preceded by a newline and indentation.
static NEW_LINE: AtomicBool = AtomicBool::new(false); static NEW_LINE: AtomicBool = const{AtomicBool::new(false)};
} }
/// An adapter that, if enabled, adds pretty print formatting. /// An adapter that, if enabled, adds pretty print formatting.

View file

@ -61,7 +61,9 @@ impl FromStr for Regex {
impl PartialEq for Regex { impl PartialEq for Regex {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
self.0.as_str().eq(other.0.as_str()) let str_left = self.0.as_str();
let str_right = other.0.as_str();
str_left == str_right
} }
} }

View file

@ -75,10 +75,6 @@ impl<I: Clone> ParseError<I> {
ref tried, ref tried,
.. ..
} }
| Self::Expected {
ref tried,
..
}
| Self::Explained { | Self::Explained {
ref tried, ref tried,
.. ..

View file

@ -1,14 +1,12 @@
mod parse;
use parse::Parse;
mod helpers; mod helpers;
mod parse;
use helpers::new_ds; use helpers::new_ds;
use surrealdb::dbs::Session; use surrealdb::dbs::Session;
use surrealdb::err::Error; use surrealdb::err::Error;
use surrealdb::sql::Value; use surrealdb::sql::Value;
use surrealdb_core::fflags::FFLAGS; use surrealdb_core::fflags::FFLAGS;
// RUST_LOG=trace cargo test -p surrealdb --features kv-mem --test live -- --nocapture
#[tokio::test] #[tokio::test]
async fn live_query_sends_registered_lq_details() -> Result<(), Error> { async fn live_query_sends_registered_lq_details() -> Result<(), Error> {
if !FFLAGS.change_feed_live_queries.enabled() { if !FFLAGS.change_feed_live_queries.enabled() {