mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-22 22:20:02 +00:00
build: specify clippy denies in cargo config (#1351)
* build: specify clippy denies in cargo config Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * deny implicit clone Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -3,3 +3,13 @@ linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
[alias]
|
||||
sqlness = "run --bin sqlness-runner --"
|
||||
|
||||
|
||||
[build]
|
||||
rustflags = [
|
||||
# lints
|
||||
# TODO: use lint configuration in cargo https://github.com/rust-lang/cargo/issues/5034
|
||||
"-Wclippy::print_stdout",
|
||||
"-Wclippy::print_stderr",
|
||||
"-Wclippy::implicit_clone",
|
||||
]
|
||||
|
||||
2
.github/workflows/develop.yml
vendored
2
.github/workflows/develop.yml
vendored
@@ -183,7 +183,7 @@ jobs:
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Run cargo clippy
|
||||
run: cargo clippy --workspace --all-targets -- -D warnings -D clippy::print_stdout -D clippy::print_stderr
|
||||
run: cargo clippy --workspace --all-targets -- -D warnings
|
||||
|
||||
coverage:
|
||||
if: github.event.pull_request.draft == false
|
||||
|
||||
@@ -51,7 +51,7 @@ GreptimeDB uses the [Apache 2.0 license](https://github.com/GreptimeTeam/greptim
|
||||
- To ensure that community is free and confident in its ability to use your contributions, please sign the Contributor License Agreement (CLA) which will be incorporated in the pull request process.
|
||||
- Make sure all your codes are formatted and follow the [coding style](https://pingcap.github.io/style-guide/rust/).
|
||||
- Make sure all unit tests are passed (using `cargo test --workspace` or [nextest](https://nexte.st/index.html) `cargo nextest run`).
|
||||
- Make sure all clippy warnings are fixed (you can check it locally by running `cargo clippy --workspace --all-targets -- -D warnings -D clippy::print_stdout -D clippy::print_stderr`).
|
||||
- Make sure all clippy warnings are fixed (you can check it locally by running `cargo clippy --workspace --all-targets -- -D warnings`).
|
||||
|
||||
#### `pre-commit` Hooks
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@@ -51,7 +51,7 @@ check: ## Cargo check all the targets.
|
||||
|
||||
.PHONY: clippy
|
||||
clippy: ## Check clippy rules.
|
||||
cargo clippy --workspace --all-targets -- -D warnings -D clippy::print_stdout -D clippy::print_stderr
|
||||
cargo clippy --workspace --all-targets -- -D warnings
|
||||
|
||||
.PHONY: fmt-check
|
||||
fmt-check: ## Check code format.
|
||||
|
||||
@@ -128,7 +128,7 @@ fn convert_record_batch(record_batch: RecordBatch) -> (Vec<Column>, u32) {
|
||||
let (values, datatype) = build_values(array);
|
||||
|
||||
let column = Column {
|
||||
column_name: field.name().to_owned(),
|
||||
column_name: field.name().clone(),
|
||||
values: Some(values),
|
||||
null_mask: array
|
||||
.data()
|
||||
|
||||
@@ -52,7 +52,7 @@ impl From<UnlockRequest> for PbUnlockRequest {
|
||||
fn from(req: UnlockRequest) -> Self {
|
||||
Self {
|
||||
header: None,
|
||||
key: req.key.to_vec(),
|
||||
key: req.key,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,6 @@ mod tests {
|
||||
let res = health_handler.handle(path, ¶ms).await.unwrap();
|
||||
|
||||
assert!(res.status().is_success());
|
||||
assert_eq!(HTTP_OK.to_owned(), res.body().to_owned());
|
||||
assert_eq!(HTTP_OK.to_owned(), res.body().clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,9 +673,9 @@ mod tests {
|
||||
let batch_get: BatchGet = req.try_into().unwrap();
|
||||
let keys = batch_get.keys;
|
||||
|
||||
assert_eq!(b"k1".to_vec(), keys.get(0).unwrap().to_vec());
|
||||
assert_eq!(b"k2".to_vec(), keys.get(1).unwrap().to_vec());
|
||||
assert_eq!(b"k3".to_vec(), keys.get(2).unwrap().to_vec());
|
||||
assert_eq!(b"k1".to_vec(), keys.get(0).unwrap().clone());
|
||||
assert_eq!(b"k2".to_vec(), keys.get(1).unwrap().clone());
|
||||
assert_eq!(b"k3".to_vec(), keys.get(2).unwrap().clone());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -707,9 +707,9 @@ mod tests {
|
||||
let batch_delete: BatchDelete = req.try_into().unwrap();
|
||||
|
||||
assert_eq!(batch_delete.keys.len(), 3);
|
||||
assert_eq!(b"k1".to_vec(), batch_delete.keys.get(0).unwrap().to_vec());
|
||||
assert_eq!(b"k2".to_vec(), batch_delete.keys.get(1).unwrap().to_vec());
|
||||
assert_eq!(b"k3".to_vec(), batch_delete.keys.get(2).unwrap().to_vec());
|
||||
assert_eq!(b"k1".to_vec(), batch_delete.keys.get(0).unwrap().clone());
|
||||
assert_eq!(b"k2".to_vec(), batch_delete.keys.get(1).unwrap().clone());
|
||||
assert_eq!(b"k3".to_vec(), batch_delete.keys.get(2).unwrap().clone());
|
||||
assert!(batch_delete.options.is_some());
|
||||
}
|
||||
|
||||
|
||||
@@ -573,7 +573,7 @@ pub(crate) fn create_alter_operation(
|
||||
create_add_columns_operation(table_name, columns, table_meta)
|
||||
}
|
||||
AlterKind::DropColumns { names } => Ok(Some(AlterOperation::DropColumns {
|
||||
names: names.to_vec(),
|
||||
names: names.clone(),
|
||||
})),
|
||||
// No need to build alter operation when reaming tables.
|
||||
AlterKind::RenameTable { .. } => Ok(None),
|
||||
|
||||
@@ -448,7 +448,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn find_region(&self, values: &[Value]) -> Result<RegionNumber, Error> {
|
||||
let val = values.get(0).unwrap().to_owned();
|
||||
let val = values.get(0).unwrap().clone();
|
||||
let id_1: Value = 1_i16.into();
|
||||
let id_2: Value = 2_i16.into();
|
||||
let id_3: Value = 3_i16.into();
|
||||
|
||||
@@ -44,7 +44,7 @@ impl PyQueryEngine {
|
||||
for rb in rbs.iter() {
|
||||
let mut vec_of_vec = Vec::with_capacity(rb.columns().len());
|
||||
for v in rb.columns() {
|
||||
let v = PyVector::from(v.to_owned());
|
||||
let v = PyVector::from(v.clone());
|
||||
let v = PyCell::new(py, v)?;
|
||||
vec_of_vec.push(v.to_object(py));
|
||||
}
|
||||
|
||||
@@ -86,21 +86,21 @@ pub fn py_obj_to_vec(
|
||||
Ok(pyv.as_vector_ref())
|
||||
} else if is_instance::<PyInt>(obj, vm) {
|
||||
let val = obj
|
||||
.to_owned()
|
||||
.clone()
|
||||
.try_into_value::<i64>(vm)
|
||||
.map_err(|e| format_py_error(e, vm))?;
|
||||
let ret = Int64Vector::from_iterator(std::iter::repeat(val).take(col_len));
|
||||
Ok(Arc::new(ret) as _)
|
||||
} else if is_instance::<PyFloat>(obj, vm) {
|
||||
let val = obj
|
||||
.to_owned()
|
||||
.clone()
|
||||
.try_into_value::<f64>(vm)
|
||||
.map_err(|e| format_py_error(e, vm))?;
|
||||
let ret = Float64Vector::from_iterator(std::iter::repeat(val).take(col_len));
|
||||
Ok(Arc::new(ret) as _)
|
||||
} else if is_instance::<PyBool>(obj, vm) {
|
||||
let val = obj
|
||||
.to_owned()
|
||||
.clone()
|
||||
.try_into_value::<bool>(vm)
|
||||
.map_err(|e| format_py_error(e, vm))?;
|
||||
|
||||
@@ -108,7 +108,7 @@ pub fn py_obj_to_vec(
|
||||
Ok(Arc::new(ret) as _)
|
||||
} else if is_instance::<PyStr>(obj, vm) {
|
||||
let val = obj
|
||||
.to_owned()
|
||||
.clone()
|
||||
.try_into_value::<String>(vm)
|
||||
.map_err(|e| format_py_error(e, vm))?;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ impl MysqlInstanceShim {
|
||||
|
||||
fn query(&self, stmt_id: u32) -> Option<String> {
|
||||
let guard = self.prepared_stmts.read();
|
||||
guard.get(&stmt_id).map(|s| s.to_owned())
|
||||
guard.get(&stmt_id).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ impl ExtendedQueryHandler for PostgresServerHandler {
|
||||
let (_, sql) = portal.statement().statement();
|
||||
|
||||
// manually replace variables in prepared statement
|
||||
let mut sql = sql.to_owned();
|
||||
let mut sql = sql.clone();
|
||||
for i in 0..portal.parameter_len() {
|
||||
sql = sql.replace(&format!("${}", i + 1), ¶meter_to_string(portal, i)?);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ impl FromRow for MysqlTextRow {
|
||||
let value = if let Some(mysql_value) = row.as_ref(i) {
|
||||
match mysql_value {
|
||||
MysqlValue::NULL => Value::Null,
|
||||
MysqlValue::Bytes(v) => Value::from(v.to_vec()),
|
||||
MysqlValue::Bytes(v) => Value::from(v.clone()),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -193,7 +193,7 @@ pub fn sql_value_to_value(
|
||||
(*b).into()
|
||||
}
|
||||
SqlValue::DoubleQuotedString(s) | SqlValue::SingleQuotedString(s) => {
|
||||
parse_string_to_value(column_name, s.to_owned(), data_type)?
|
||||
parse_string_to_value(column_name, s.clone(), data_type)?
|
||||
}
|
||||
SqlValue::HexStringLiteral(s) => parse_hex_string(s)?,
|
||||
SqlValue::Placeholder(s) => return InvalidSqlValueSnafu { value: s }.fail(),
|
||||
|
||||
Reference in New Issue
Block a user