Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
photino committed Jul 5, 2023
1 parent 2c477f7 commit eccb7aa
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion examples/actix-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
actix-web = "4.3.1"
fluent = "0.16.0"
serde_json = "1.0.99"
serde_json = "1.0.100"
tracing = "0.1.37"

[dependencies.serde]
Expand Down
2 changes: 1 addition & 1 deletion examples/axum-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
axum = "0.6.18"
fluent = "0.16.0"
serde_json = "1.0.99"
serde_json = "1.0.100"
tracing = "0.1.37"

[dependencies.serde]
Expand Down
2 changes: 1 addition & 1 deletion zino-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ version = "1.0.164"
features = ["derive"]

[dependencies.serde_json]
version = "1.0.99"
version = "1.0.100"
features = ["raw_value"]

[dependencies.sqlx]
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/chatbot/chatbot_openai.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{chatbot::ChatbotClient::OpenAi, Chatbot, ChatbotService};
use super::{client::ChatbotClient::OpenAi, Chatbot, ChatbotService};
use crate::{
application::http_client,
error::Error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Chatbot {
"openai" => OpenAiChatCompletion::try_new_chatbot(config),
_ => {
let message = format!("chatbot service `{service}` is unsupported");
return Err(Error::new(message));
Err(Error::new(message))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions zino-core/src/chatbot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use crate::{error::Error, extension::TomlTableExt, state::State, Map};
use std::sync::LazyLock;
use toml::Table;

mod chatbot;
mod client;

/// Supported chatbot services.
#[cfg(feature = "chatbot-openai")]
mod chatbot_openai;

pub use chatbot::Chatbot;
pub use client::Chatbot;

#[cfg(feature = "chatbot-openai")]
use chatbot_openai::OpenAiChatCompletion;
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/connector/connector_arrow/arrow_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl ArrowArrayExt for dyn Array {
let position = dictionary_array.lookup_key(value).ok_or_else(|| {
Error::new(format!("value `{value}` is not in the dictionary"))
})?;
AvroValue::Enum(position.try_into()?, value.to_owned())
AvroValue::Enum(position, value.to_owned())
}
data_type => {
let message = format!("cannot convert the `{data_type}` value to an Avro value");
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/connector/connector_arrow/arrow_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl ArrowSchemaExt for Schema {
TomlValue::Array(array) => {
let length = array.len();
if length == 1 && let Some(TomlValue::String(value_type)) = array.first() {
let item_data_type = parse_arrow_data_type(&value_type)?;
let item_data_type = parse_arrow_data_type(value_type)?;
let field = Field::new("item", item_data_type, true);
DataType::List(Arc::new(field))
} else if length >= 2 {
Expand Down
10 changes: 4 additions & 6 deletions zino-core/src/connector/connector_arrow/data_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ impl DataFrameExecutor for DataFrame {
for field in &batch.schema().fields {
let field_name = field.name().as_str();
if let Some(array) = batch.column_by_name(field_name) {
for i in 0..num_rows {
let record = &mut records[i];
let value = array.parse_avro_value(i)?;
for (index, record) in records.iter_mut().enumerate() {
let value = array.parse_avro_value(index)?;
record.push((field_name.to_owned(), value));
}
}
Expand All @@ -67,9 +66,8 @@ impl DataFrameExecutor for DataFrame {
for field in &batch.schema().fields {
let field_name = field.name().as_str();
if let Some(array) = batch.column_by_name(field_name) {
for i in 0..num_rows {
let map = &mut data[i];
let value = array.parse_json_value(i)?;
for (index, map) in data.iter_mut().enumerate() {
let value = array.parse_json_value(index)?;
map.insert(field_name.to_owned(), value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/connector/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl DataSource {
/// Returns the protocol.
#[inline]
pub fn protocol(&self) -> &'static str {
&self.protocol
self.protocol
}

/// Returns the data source type.
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait Connector {
let data = self.query(query, params).await?;
let value = data
.into_iter()
.map(|record| AvroValue::Record(record))
.map(AvroValue::Record)
.collect::<Vec<_>>();
apache_avro::from_value(&AvroValue::Array(value)).map_err(|err| err.into())
}
Expand Down
14 changes: 4 additions & 10 deletions zino-core/src/database/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
.collect::<Vec<_>>();
format!(r#"json_array({})"#, values.join(",")).into()
}
JsonValue::Object(_) => {
let value = Query::escape_string(value);
format!("{value}").into()
}
JsonValue::Object(_) => Query::escape_string(value).into(),
}
} else if self.default_value().is_some() {
"DEFAULT".into()
Expand Down Expand Up @@ -140,7 +137,7 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
"midnight" => "'00:00:00'".into(),
_ => Query::escape_string(value).into(),
},
"Vec<u8>" => format!("'value'").into(),
"Vec<u8>" => format!("'{value}'").into(),
"Vec<String>" | "Vec<Uuid>" => {
if value.contains(',') {
let values = value
Expand All @@ -153,10 +150,7 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
format!(r#"json_array({value})"#).into()
}
}
"Map" => {
let value = Query::escape_string(value);
format!("{value}").into()
}
"Map" => Query::escape_string(value).into(),
_ => "NULL".into(),
}
}
Expand Down Expand Up @@ -365,7 +359,7 @@ impl DecodeRow<DatabaseRow> for Map {
"DOUBLE" => decode_column::<f64>(field, raw_value)?.into(),
"NUMERIC" => {
let value = decode_column::<Decimal>(field, raw_value)?;
serde_json::to_value(&value)?
serde_json::to_value(value)?
}
"TEXT" | "VARCHAR" | "CHAR" => {
decode_column::<String>(field, raw_value)?.into()
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/encoding/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ pub(crate) fn decode(data: impl AsRef<[u8]>) -> Result<Vec<u8>, DecodeError> {
pub(crate) fn encode_data_url(data: impl AsRef<[u8]>) -> String {
let bytes = data.as_ref();
let mut data = String::with_capacity(bytes.len() * 3 / 4);
base64::engine::general_purpose::STANDARD.encode_string(&bytes, &mut data);
base64::engine::general_purpose::STANDARD.encode_string(bytes, &mut data);
format!("data:text/plain;base64,{data}")
}
2 changes: 1 addition & 1 deletion zino/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ futures = "0.3.28"
hyper = "0.14.27"
parking_lot = "0.12.1"
serde = "1.0.163"
serde_json = "1.0.99"
serde_json = "1.0.100"
toml = "0.7.3"
tracing = "0.1.37"

Expand Down

0 comments on commit eccb7aa

Please sign in to comment.