mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
fix clippy
This commit is contained in:
parent
874499a2d2
commit
e9055f5572
31 changed files with 125 additions and 124 deletions
|
@ -1,3 +1,6 @@
|
|||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::wrong_self_convention)]
|
||||
|
||||
use meilisearch_types::error::ResponseError;
|
||||
use meilisearch_types::keys::Key;
|
||||
use meilisearch_types::milli::update::IndexDocumentsMethod;
|
||||
|
@ -99,7 +102,7 @@ pub enum KindDump {
|
|||
},
|
||||
DocumentClear,
|
||||
Settings {
|
||||
settings: meilisearch_types::settings::Settings<Unchecked>,
|
||||
settings: Box<meilisearch_types::settings::Settings<Unchecked>>,
|
||||
is_deletion: bool,
|
||||
allow_index_creation: bool,
|
||||
},
|
||||
|
@ -369,7 +372,7 @@ pub(crate) mod test {
|
|||
|
||||
pub fn create_test_dump() -> File {
|
||||
let instance_uid = create_test_instance_uid();
|
||||
let dump = DumpWriter::new(Some(instance_uid.clone())).unwrap();
|
||||
let dump = DumpWriter::new(Some(instance_uid)).unwrap();
|
||||
|
||||
// ========== Adding an index
|
||||
let documents = create_test_documents();
|
||||
|
|
|
@ -74,7 +74,7 @@ impl CompatV3ToV4 {
|
|||
.map(|index| index.uid.clone());
|
||||
|
||||
let index_uid = match index_uid {
|
||||
Some(uid) => uid.to_string(),
|
||||
Some(uid) => uid,
|
||||
None => {
|
||||
log::warn!(
|
||||
"Error while importing the update {}.",
|
||||
|
@ -120,7 +120,7 @@ impl CompatV3ToV4 {
|
|||
primary_key: primary_key.clone(),
|
||||
documents_count: 0, // we don't have this info
|
||||
allow_index_creation: true, // there was no API-key in the v3
|
||||
content_uuid: content_uuid.clone(),
|
||||
content_uuid: *content_uuid,
|
||||
},
|
||||
v3::Kind::Settings(settings) => {
|
||||
v4::tasks::TaskContent::SettingsUpdate {
|
||||
|
|
|
@ -51,7 +51,7 @@ impl CompatV5ToV6 {
|
|||
pub fn tasks(
|
||||
&mut self,
|
||||
) -> Result<Box<dyn Iterator<Item = Result<(v6::Task, Option<Box<UpdateFile>>)>> + '_>> {
|
||||
let instance_uid = self.instance_uid().ok().flatten().map(|uid| uid.clone());
|
||||
let instance_uid = self.instance_uid().ok().flatten();
|
||||
let keys = self.keys()?.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
let tasks = match self {
|
||||
|
@ -59,7 +59,7 @@ impl CompatV5ToV6 {
|
|||
CompatV5ToV6::Compat(compat) => compat.tasks(),
|
||||
};
|
||||
Ok(Box::new(tasks.map(move |task| {
|
||||
task.and_then(|(task, content_file)| {
|
||||
task.map(|(task, content_file)| {
|
||||
let mut task_view: v5::tasks::TaskView = task.clone().into();
|
||||
|
||||
if task_view.status == v5::Status::Processing {
|
||||
|
@ -75,7 +75,7 @@ impl CompatV5ToV6 {
|
|||
v5::Status::Succeeded => v6::Status::Succeeded,
|
||||
v5::Status::Failed => v6::Status::Failed,
|
||||
},
|
||||
kind: match task.content.clone() {
|
||||
kind: match task.content {
|
||||
v5::tasks::TaskContent::IndexCreation { primary_key, .. } => {
|
||||
v6::Kind::IndexCreation { primary_key }
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl CompatV5ToV6 {
|
|||
v6::milli::update::IndexDocumentsMethod::UpdateDocuments
|
||||
}
|
||||
},
|
||||
allow_index_creation: allow_index_creation.clone(),
|
||||
allow_index_creation,
|
||||
},
|
||||
v5::tasks::TaskContent::DocumentDeletion { deletion, .. } => match deletion
|
||||
{
|
||||
|
@ -117,13 +117,11 @@ impl CompatV5ToV6 {
|
|||
} => v6::Kind::Settings {
|
||||
is_deletion,
|
||||
allow_index_creation,
|
||||
settings: settings.into(),
|
||||
},
|
||||
v5::tasks::TaskContent::Dump { uid } => v6::Kind::DumpExport {
|
||||
dump_uid: uid,
|
||||
keys: keys.clone(),
|
||||
instance_uid: instance_uid.clone(),
|
||||
settings: Box::new(settings.into()),
|
||||
},
|
||||
v5::tasks::TaskContent::Dump { uid } => {
|
||||
v6::Kind::DumpExport { dump_uid: uid, keys: keys.clone(), instance_uid }
|
||||
}
|
||||
},
|
||||
canceled_by: None,
|
||||
details: task_view.details.map(|details| match details {
|
||||
|
@ -134,7 +132,7 @@ impl CompatV5ToV6 {
|
|||
}
|
||||
}
|
||||
v5::Details::Settings { settings } => {
|
||||
v6::Details::SettingsUpdate { settings: settings.into() }
|
||||
v6::Details::SettingsUpdate { settings: Box::new(settings.into()) }
|
||||
}
|
||||
v5::Details::IndexInfo { primary_key } => {
|
||||
v6::Details::IndexInfo { primary_key }
|
||||
|
@ -157,7 +155,7 @@ impl CompatV5ToV6 {
|
|||
finished_at: task_view.finished_at,
|
||||
};
|
||||
|
||||
Ok((task, content_file))
|
||||
(task, content_file)
|
||||
})
|
||||
})))
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ impl From<CompatV4ToV5> for DumpReader {
|
|||
|
||||
pub enum DumpIndexReader {
|
||||
Current(v6::V6IndexReader),
|
||||
Compat(CompatIndexV5ToV6),
|
||||
Compat(Box<CompatIndexV5ToV6>),
|
||||
}
|
||||
|
||||
impl DumpIndexReader {
|
||||
|
@ -176,7 +176,7 @@ impl From<V6IndexReader> for DumpIndexReader {
|
|||
|
||||
impl From<CompatIndexV5ToV6> for DumpIndexReader {
|
||||
fn from(value: CompatIndexV5ToV6) -> Self {
|
||||
DumpIndexReader::Compat(value)
|
||||
DumpIndexReader::Compat(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,10 +105,10 @@ impl V2Reader {
|
|||
|
||||
pub fn indexes(&self) -> Result<impl Iterator<Item = Result<V2IndexReader>> + '_> {
|
||||
Ok(self.index_uuid.iter().map(|index| -> Result<_> {
|
||||
Ok(V2IndexReader::new(
|
||||
V2IndexReader::new(
|
||||
index.uid.clone(),
|
||||
&self.dump.path().join("indexes").join(format!("index-{}", index.uuid.to_string())),
|
||||
)?)
|
||||
&self.dump.path().join("indexes").join(format!("index-{}", index.uuid)),
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ impl V2Reader {
|
|||
.path()
|
||||
.join("updates")
|
||||
.join("update_files")
|
||||
.join(format!("update_{}", uuid.to_string()));
|
||||
.join(format!("update_{}", uuid));
|
||||
Ok((task, Some(UpdateFile::new(&update_file_path)?)))
|
||||
} else {
|
||||
Ok((task, None))
|
||||
|
|
|
@ -111,10 +111,10 @@ impl V3Reader {
|
|||
|
||||
pub fn indexes(&self) -> Result<impl Iterator<Item = Result<V3IndexReader>> + '_> {
|
||||
Ok(self.index_uuid.iter().map(|index| -> Result<_> {
|
||||
Ok(V3IndexReader::new(
|
||||
V3IndexReader::new(
|
||||
index.uid.clone(),
|
||||
&self.dump.path().join("indexes").join(index.uuid.to_string()),
|
||||
)?)
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ pub struct Facets {
|
|||
pub min_level_size: Option<NonZeroUsize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Setting<T> {
|
||||
Set(T),
|
||||
Reset,
|
||||
|
|
|
@ -97,10 +97,10 @@ impl V4Reader {
|
|||
|
||||
pub fn indexes(&self) -> Result<impl Iterator<Item = Result<V4IndexReader>> + '_> {
|
||||
Ok(self.index_uuid.iter().map(|index| -> Result<_> {
|
||||
Ok(V4IndexReader::new(
|
||||
V4IndexReader::new(
|
||||
index.uid.clone(),
|
||||
&self.dump.path().join("indexes").join(index.index_meta.uuid.to_string()),
|
||||
)?)
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -23,15 +23,15 @@ where
|
|||
.serialize(s)
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq)]
|
||||
#[derive(Clone, Default, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
pub struct Checked;
|
||||
|
||||
#[derive(Clone, Default, Debug, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Default, Debug, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
pub struct Unchecked;
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -42,7 +42,7 @@ pub struct MinWordSizeTyposSetting {
|
|||
pub two_typos: Setting<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -59,7 +59,7 @@ pub struct TypoSettings {
|
|||
/// Holds all the settings for an index. `T` can either be `Checked` if they represents settings
|
||||
/// whose validity is guaranteed, or `Unchecked` if they need to be validated. In the later case, a
|
||||
/// call to `check` will return a `Settings<Checked>` from a `Settings<Unchecked>`.
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -191,7 +191,7 @@ pub struct Facets {
|
|||
pub min_level_size: Option<NonZeroUsize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||
pub enum Setting<T> {
|
||||
Set(T),
|
||||
Reset,
|
||||
|
|
|
@ -9,7 +9,7 @@ use super::settings::{Settings, Unchecked};
|
|||
pub type TaskId = u32;
|
||||
pub type BatchId = u32;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
pub struct Task {
|
||||
pub id: TaskId,
|
||||
|
@ -18,7 +18,7 @@ pub struct Task {
|
|||
pub events: Vec<TaskEvent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TaskContent {
|
||||
|
|
|
@ -138,10 +138,10 @@ impl V5Reader {
|
|||
|
||||
pub fn indexes(&self) -> Result<impl Iterator<Item = Result<V5IndexReader>> + '_> {
|
||||
Ok(self.index_uuid.iter().map(|index| -> Result<_> {
|
||||
Ok(V5IndexReader::new(
|
||||
V5IndexReader::new(
|
||||
index.uid.clone(),
|
||||
&self.dump.path().join("indexes").join(index.index_meta.uuid.to_string()),
|
||||
)?)
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ pub struct Unchecked;
|
|||
/// Holds all the settings for an index. `T` can either be `Checked` if they represents settings
|
||||
/// whose validity is guaranteed, or `Unchecked` if they need to be validated. In the later case, a
|
||||
/// call to `check` will return a `Settings<Checked>` from a `Settings<Unchecked>`.
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -47,7 +47,7 @@ pub struct Settings<T> {
|
|||
pub _kind: PhantomData<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
pub enum Setting<T> {
|
||||
Set(T),
|
||||
|
@ -102,7 +102,7 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Setting<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -113,7 +113,7 @@ pub struct MinWordSizeTyposSetting {
|
|||
pub two_typos: Setting<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -128,7 +128,7 @@ pub struct TypoSettings {
|
|||
pub disable_on_attributes: Setting<BTreeSet<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -137,7 +137,7 @@ pub struct FacetingSettings {
|
|||
pub max_values_per_facet: Setting<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
|
@ -9,7 +9,7 @@ use super::settings::{Settings, Unchecked};
|
|||
pub type TaskId = u32;
|
||||
pub type BatchId = u32;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
pub struct Task {
|
||||
pub id: TaskId,
|
||||
|
@ -21,7 +21,7 @@ pub struct Task {
|
|||
pub events: Vec<TaskEvent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(serde::Serialize))]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TaskContent {
|
||||
|
|
|
@ -108,7 +108,7 @@ impl V6Reader {
|
|||
.path()
|
||||
.join("tasks")
|
||||
.join("update_files")
|
||||
.join(format!("{}.jsonl", task.uid.to_string()));
|
||||
.join(format!("{}.jsonl", task.uid));
|
||||
|
||||
if update_file_path.exists() {
|
||||
Ok((
|
||||
|
|
|
@ -233,13 +233,13 @@ pub(crate) mod test {
|
|||
let mut ident = String::new();
|
||||
|
||||
for _ in 0..depth {
|
||||
ident.push_str(&"│");
|
||||
ident.push('│');
|
||||
ident.push_str(&" ".repeat(4));
|
||||
}
|
||||
if idx == entries.len() - 1 {
|
||||
ident.push_str(&"└");
|
||||
ident.push('└');
|
||||
} else {
|
||||
ident.push_str(&"├");
|
||||
ident.push('├');
|
||||
}
|
||||
ident.push_str(&"-".repeat(4));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue