Skip to content

Commit

Permalink
ci: enable lint check for workspace members (tailcallhq#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill authored Jan 31, 2024
1 parent e1fec68 commit 661fe7d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
30 changes: 16 additions & 14 deletions autogen/src/gen_gql_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use schemars::schema::{
};
use tailcall::config;

static GRAPHQL_SCHEMA_FILE: &'static str = "generated/.tailcallrc.graphql";
static DIRECTIVE_WHITELIST: [(&'static str, Entity, bool); 12] = [
static GRAPHQL_SCHEMA_FILE: &str = "generated/.tailcallrc.graphql";
static DIRECTIVE_WHITELIST: [(&str, Entity, bool); 12] = [
("server", Entity::Schema, false),
("upstream", Entity::Schema, false),
("http", Entity::FieldDefinition, false),
Expand All @@ -23,7 +23,7 @@ static DIRECTIVE_WHITELIST: [(&'static str, Entity, bool); 12] = [
("expr", Entity::FieldDefinition, false),
("js", Entity::FieldDefinition, false),
];
static OBJECT_WHITELIST: [&'static str; 18] = [
static OBJECT_WHITELIST: [&str; 18] = [
"ExprBody",
"If",
"Http",
Expand Down Expand Up @@ -124,6 +124,7 @@ impl<W: Write> IndentedWriter<W> {
}

impl<W: std::io::Write> Write for IndentedWriter<W> {
#[allow(clippy::same_item_push)]
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
let mut new_buf = vec![];
let mut extra = 0;
Expand Down Expand Up @@ -185,10 +186,10 @@ fn write_instance_type(

fn write_reference(
writer: &mut IndentedWriter<impl Write>,
reference: &String,
reference: &str,
extra_it: &mut BTreeMap<String, ExtraTypes>,
) -> std::io::Result<()> {
let mut nm = reference.split("/").last().unwrap().to_string();
let mut nm = reference.split('/').last().unwrap().to_string();
first_char_to_upper(&mut nm);
extra_it.insert(nm.clone(), ExtraTypes::Schema);
write!(writer, "{nm}")
Expand All @@ -208,6 +209,7 @@ fn first_char_to_upper(name: &mut String) {
}
}

#[allow(clippy::too_many_arguments)]
fn write_type(
writer: &mut IndentedWriter<impl Write>,
name: String,
Expand Down Expand Up @@ -245,7 +247,7 @@ fn write_type(
if let Some(arr_valid) = schema.array.clone() {
write_array_validation(writer, name, *arr_valid, defs, extra_it)
} else if let Some(typ) = schema.object.clone() {
if typ.properties.len() > 0 {
if !typ.properties.is_empty() {
let mut name = name;
first_char_to_upper(&mut name);
write!(writer, "{name}")?;
Expand Down Expand Up @@ -280,7 +282,7 @@ fn write_type(
}
}
}

#[allow(clippy::too_many_arguments)]
fn write_field(
writer: &mut IndentedWriter<impl Write>,
name: String,
Expand All @@ -290,9 +292,9 @@ fn write_field(
) -> std::io::Result<()> {
write!(writer, "{name}: ")?;
write_type(writer, name, schema, defs, extra_it)?;
writeln!(writer, "")
writeln!(writer)
}

#[allow(clippy::too_many_arguments)]
fn write_input_type(
writer: &mut IndentedWriter<impl Write>,
name: String,
Expand Down Expand Up @@ -386,7 +388,7 @@ fn write_input_type(

Ok(())
}

#[allow(clippy::too_many_arguments)]
fn write_property(
writer: &mut IndentedWriter<impl Write>,
name: String,
Expand Down Expand Up @@ -429,7 +431,7 @@ fn input_whitelist_lookup<'a>(

None
}

#[allow(clippy::too_many_arguments)]
fn write_directive(
writer: &mut IndentedWriter<impl Write>,
name: String,
Expand Down Expand Up @@ -506,7 +508,7 @@ fn write_all_directives(

Ok(())
}

#[allow(clippy::too_many_arguments)]
fn write_array_validation(
writer: &mut IndentedWriter<impl Write>,
name: String,
Expand All @@ -532,15 +534,15 @@ fn write_array_validation(
}
write!(writer, "]")
}

#[allow(clippy::too_many_arguments)]
fn write_object_validation(
writer: &mut IndentedWriter<impl Write>,
name: String,
obj_valid: ObjectValidation,
defs: &BTreeMap<String, Schema>,
extra_it: &mut BTreeMap<String, ExtraTypes>,
) -> std::io::Result<()> {
if obj_valid.properties.len() > 0 {
if !obj_valid.properties.is_empty() {
writeln!(writer, "input {name} {{")?;
writer.indent();
for (name, property) in obj_valid.properties {
Expand Down
2 changes: 1 addition & 1 deletion autogen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde_json::{json, Value};
use tailcall::cli::init_file;
use tailcall::config;

static JSON_SCHEMA_FILE: &'static str = "../generated/.tailcallrc.schema.json";
static JSON_SCHEMA_FILE: &str = "../generated/.tailcallrc.schema.json";

#[tokio::main]
async fn main() {
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub async fn fetch(req: worker::Request, env: worker::Env) -> anyhow::Result<wor
let app_ctx = get_app_ctx(env, config_path.as_str()).await?;
let resp = handle_request::<GraphQLRequest>(hyper_req, app_ctx).await?;

Ok(to_response(resp).await?)
to_response(resp).await
}

///
Expand Down
1 change: 1 addition & 0 deletions cloudflare/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn init_env(env: Rc<worker::Env>) -> Arc<dyn EnvIO> {
}

pub fn init_file(env: Rc<worker::Env>, bucket_id: String) -> anyhow::Result<Arc<dyn FileIO>> {
#[allow(clippy::arc_with_non_send_sync)]
Ok(Arc::new(file::CloudflareFileIO::init(env, bucket_id)?))
}

Expand Down
6 changes: 3 additions & 3 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ FILE_TYPES="{graphql,yml,json,md,ts,js}"
run_cargo_fmt() {
MODE=$1
if [ "$MODE" == "check" ]; then
cargo +nightly fmt -- --check
cargo +nightly fmt --all -- --check
else
cargo +nightly fmt
cargo +nightly fmt --all
fi
return $?
}

run_cargo_clippy() {
MODE=$1
CMD="cargo +nightly clippy --all-targets --all-features"
CMD="cargo +nightly clippy --all --all-targets --all-features"
if [ "$MODE" == "fix" ]; then
$CMD --fix --allow-staged --allow-dirty
fi
Expand Down

0 comments on commit 661fe7d

Please sign in to comment.