Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Updated lint configuration, fixed lint errors and warnings #431

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This is high as but it's a maximum and we'll tune as we go.
cognitive-complexity-threshold = 30
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions crates/components/wick-http-client/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl HttpClientComponent {
.and_then(|r| r.try_url())
.into_component_error()?;

let mut sig = ComponentSignature::new("wick/component/http");
let mut sig = ComponentSignature::new_named("wick/component/http");
sig.metadata.version = metadata.map(|v| v.version().to_owned());
sig.operations = config.operation_signatures();
sig.config = config.config().to_vec();
Expand Down Expand Up @@ -145,11 +145,8 @@ async fn handle(
if baseurl.cannot_be_a_base() {
return Err(Error::InvalidBaseUrl(baseurl).into());
}
let opdef = match opdef {
Some(opdef) => opdef,
None => {
return Err(Error::OpNotFound(invocation.target.operation_id().to_owned()).into());
}
let Some(opdef) = opdef else {
return Err(Error::OpNotFound(invocation.target.operation_id().to_owned()).into());
};
// Defer to operation codec, then to client codec, then to default.
let codec = opdef.codec().copied().unwrap_or(codec.unwrap_or_default());
Expand Down Expand Up @@ -403,8 +400,8 @@ mod test {
use super::*;

#[test]
fn test_component() {
fn is_send_sync<T: Send + Sync>() {}
const fn test_component() {
const fn is_send_sync<T: Send + Sync>() {}
is_send_sync::<HttpClientComponent>();
}

Expand Down
1 change: 1 addition & 0 deletions crates/components/wick-http-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use flow_component::ComponentError;
use url::Url;

#[derive(thiserror::Error, Debug, PartialEq)]
#[non_exhaustive]
pub enum Error {
#[error("Bad configuration: {0}")]
Validation(String),
Expand Down
69 changes: 48 additions & 21 deletions crates/components/wick-http-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,75 @@
// This is automatically generated. Add exceptions after this section.
#![allow(unknown_lints)]
#![deny(
clippy::expect_used,
clippy::explicit_deref_methods,
clippy::option_if_let_else,
clippy::await_holding_lock,
clippy::borrow_as_ptr,
clippy::branches_sharing_code,
clippy::cast_lossless,
clippy::clippy::collection_is_never_read,
clippy::cloned_instead_of_copied,
clippy::cognitive_complexity,
clippy::create_dir,
clippy::deref_by_slicing,
clippy::derivable_impls,
clippy::derive_partial_eq_without_eq,
clippy::equatable_if_let,
clippy::exhaustive_structs,
clippy::expect_used,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop,
clippy::explicit_iter_loop,
clippy::filetype_is_file,
clippy::flat_map_option,
clippy::format_push_string,
clippy::fn_params_excessive_bools,
clippy::future_not_send,
clippy::get_unwrap,
clippy::implicit_clone,
clippy::if_then_some_else_none,
clippy::impl_trait_in_params,
clippy::implicit_clone,
clippy::inefficient_to_string,
clippy::inherent_to_string,
clippy::iter_not_returning_iterator,
clippy::large_types_passed_by_value,
clippy::large_include_file,
clippy::let_and_return,
clippy::manual_assert,
clippy::manual_ok_or,
clippy::manual_split_once,
clippy::manual_let_else,
clippy::manual_string_new,
clippy::map_flatten,
clippy::map_unwrap_or,
clippy::missing_enforced_import_renames,
clippy::missing_assert_message,
clippy::missing_const_for_fn,
clippy::must_use_candidate,
clippy::mut_mut,
clippy::needless_for_each,
clippy::needless_option_as_deref,
clippy::needless_pass_by_value,
clippy::needless_collect,
clippy::needless_continue,
clippy::non_send_fields_in_send_ty,
clippy::nonstandard_macro_braces,
clippy::option_if_let_else,
clippy::option_option,
clippy::rc_mutex,
clippy::redundant_else,
clippy::same_name_method,
clippy::semicolon_if_nothing_returned,
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref,
clippy::unnested_or_patterns,
clippy::future_not_send,
clippy::useless_let_if_seq,
clippy::str_to_string,
clippy::inherent_to_string,
clippy::let_and_return,
clippy::string_to_string,
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref,
clippy::trivial_regex,
clippy::try_err,
clippy::unnested_or_patterns,
clippy::unused_async,
clippy::missing_enforced_import_renames,
clippy::nonstandard_macro_braces,
clippy::rc_mutex,
clippy::unwrap_or_else_default,
clippy::manual_split_once,
clippy::derivable_impls,
clippy::needless_option_as_deref,
clippy::iter_not_returning_iterator,
clippy::same_name_method,
clippy::manual_assert,
clippy::non_send_fields_in_send_ty,
clippy::equatable_if_let,
clippy::useless_let_if_seq,
bad_style,
clashing_extern_declarations,
dead_code,
Expand Down Expand Up @@ -80,6 +106,7 @@
while_true,
missing_docs
)]
#![warn(clippy::exhaustive_enums)]
#![allow(unused_attributes, clippy::derive_partial_eq_without_eq, clippy::box_default)]
// !!END_LINTS
// Add exceptions here
Expand Down
2 changes: 1 addition & 1 deletion crates/components/wick-sql/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ fn normalize_inline_ids(orig_query: &str, mut orig_args: Vec<String>) -> (Cow<st

let normalized = WICK_ID_ARGS.replace_all(orig_query, |cap: &Captures| {
let id = cap.name("id").unwrap().as_str();
let id = id_map.get(id).unwrap();
let id = id_map[id];
format!("${}", id)
});
debug!(%orig_query,%normalized, "sql:inline-replacement");
Expand Down
1 change: 1 addition & 0 deletions crates/components/wick-sql/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use wick_packet::TypeWrapper;

#[derive(thiserror::Error, Debug)]
#[allow(missing_docs)]
#[non_exhaustive]
pub enum Error {
#[error("Invalid output for operations {}. At this time postgres operations can have at most one output named 'output' of type 'object'", .0.join(", "))]
InvalidOutput(Vec<String>),
Expand Down
69 changes: 48 additions & 21 deletions crates/components/wick-sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,75 @@
// This is automatically generated. Add exceptions after this section.
#![allow(unknown_lints)]
#![deny(
clippy::expect_used,
clippy::explicit_deref_methods,
clippy::option_if_let_else,
clippy::await_holding_lock,
clippy::borrow_as_ptr,
clippy::branches_sharing_code,
clippy::cast_lossless,
clippy::clippy::collection_is_never_read,
clippy::cloned_instead_of_copied,
clippy::cognitive_complexity,
clippy::create_dir,
clippy::deref_by_slicing,
clippy::derivable_impls,
clippy::derive_partial_eq_without_eq,
clippy::equatable_if_let,
clippy::exhaustive_structs,
clippy::expect_used,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop,
clippy::explicit_iter_loop,
clippy::filetype_is_file,
clippy::flat_map_option,
clippy::format_push_string,
clippy::fn_params_excessive_bools,
clippy::future_not_send,
clippy::get_unwrap,
clippy::implicit_clone,
clippy::if_then_some_else_none,
clippy::impl_trait_in_params,
clippy::implicit_clone,
clippy::inefficient_to_string,
clippy::inherent_to_string,
clippy::iter_not_returning_iterator,
clippy::large_types_passed_by_value,
clippy::large_include_file,
clippy::let_and_return,
clippy::manual_assert,
clippy::manual_ok_or,
clippy::manual_split_once,
clippy::manual_let_else,
clippy::manual_string_new,
clippy::map_flatten,
clippy::map_unwrap_or,
clippy::missing_enforced_import_renames,
clippy::missing_assert_message,
clippy::missing_const_for_fn,
clippy::must_use_candidate,
clippy::mut_mut,
clippy::needless_for_each,
clippy::needless_option_as_deref,
clippy::needless_pass_by_value,
clippy::needless_collect,
clippy::needless_continue,
clippy::non_send_fields_in_send_ty,
clippy::nonstandard_macro_braces,
clippy::option_if_let_else,
clippy::option_option,
clippy::rc_mutex,
clippy::redundant_else,
clippy::same_name_method,
clippy::semicolon_if_nothing_returned,
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref,
clippy::unnested_or_patterns,
clippy::future_not_send,
clippy::useless_let_if_seq,
clippy::str_to_string,
clippy::inherent_to_string,
clippy::let_and_return,
clippy::string_to_string,
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref,
clippy::trivial_regex,
clippy::try_err,
clippy::unnested_or_patterns,
clippy::unused_async,
clippy::missing_enforced_import_renames,
clippy::nonstandard_macro_braces,
clippy::rc_mutex,
clippy::unwrap_or_else_default,
clippy::manual_split_once,
clippy::derivable_impls,
clippy::needless_option_as_deref,
clippy::iter_not_returning_iterator,
clippy::same_name_method,
clippy::manual_assert,
clippy::non_send_fields_in_send_ty,
clippy::equatable_if_let,
clippy::useless_let_if_seq,
bad_style,
clashing_extern_declarations,
dead_code,
Expand Down Expand Up @@ -82,6 +108,7 @@
while_true,
missing_docs
)]
#![warn(clippy::exhaustive_enums)]
#![allow(unused_attributes, clippy::derive_partial_eq_without_eq, clippy::box_default)]
// !!END_LINTS
// Add exceptions here
Expand Down
4 changes: 2 additions & 2 deletions crates/components/wick-sql/src/mssql_tiberius/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ mod test {
use super::*;

#[test]
fn test_component() {
fn is_send_sync<T: Sync>() {}
const fn test_component() {
const fn is_send_sync<T: Sync>() {}
is_send_sync::<AzureSqlComponent>();
}

Expand Down
4 changes: 2 additions & 2 deletions crates/components/wick-sql/src/sqlx/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ mod test {
use super::*;

#[test]
fn test_component() {
fn is_send_sync<T: Sync>() {}
const fn test_component() {
const fn is_send_sync<T: Sync>() {}
is_send_sync::<SqlXComponent>();
}

Expand Down
1 change: 1 addition & 0 deletions crates/components/wick-sql/src/sqlx/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(crate) async fn connect(_config: &SqlComponentConfig, addr: &Url) -> Result<
Ok(pool)
}

#[allow(clippy::cast_lossless)]
pub(crate) fn make_query(
sql: &str,
args: Vec<ConvertedType>,
Expand Down
1 change: 1 addition & 0 deletions crates/components/wick-sql/src/sqlx/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(crate) async fn connect(_config: &SqlComponentConfig, addr: Option<&str>) ->
Ok(pool)
}

#[allow(clippy::cast_lossless)]
pub(crate) fn make_query(
sql: &str,
args: Vec<ConvertedType>,
Expand Down
1 change: 1 addition & 0 deletions crates/interfaces/wick-interface-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"
license = "Apache-2.0"
description = "CLI interface types for the wick framework and components"
repository = "https://github.com/candlecorp/wick"
readme = "README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand Down
3 changes: 3 additions & 0 deletions crates/interfaces/wick-interface-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# wick-interface-cli

Types and data structures for Wick CLI trigger components.
4 changes: 3 additions & 1 deletion crates/interfaces/wick-interface-cli/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=component.yaml");
#[cfg(not(feature = "localgen"))]
wick_component_codegen::configure().generate("component.yaml")?;
wick_component_codegen::configure()
.components(false)
.generate("component.yaml")?;

#[cfg(feature = "localgen")]
{
Expand Down
Loading