mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
Ban println!
in code with clippy (#711)
<!-- Thank you for submitting this PR! :) --> ## Description A few debug lines slipped in recently, let's make `clippy` `warn` on those, so they are kicked out by CI. Functional no-op. V3_GIT_ORIGIN_REV_ID: 290f6de35f9315b68811eb5f15969fb0333e9d06
This commit is contained in:
parent
9d43502e18
commit
eba79698d5
@ -22,6 +22,9 @@ members = [
|
||||
[workspace.lints.clippy]
|
||||
all = { level = "warn", priority = -1 }
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
# ban printing to stdout and stderr
|
||||
print_stdout = "warn"
|
||||
print_stderr = "warn"
|
||||
# disable certain pedantic warnings
|
||||
doc_markdown = "allow"
|
||||
implicit_hasher = "allow"
|
||||
|
@ -91,6 +91,7 @@ struct EngineState {
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
#[allow(clippy::print_stdout)]
|
||||
async fn main() {
|
||||
let server = ServerOptions::parse();
|
||||
|
||||
@ -276,6 +277,7 @@ impl EngineRouter {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
async fn start_engine(server: &ServerOptions) -> Result<(), StartupError> {
|
||||
let auth_config =
|
||||
read_auth_config(&server.authn_config_path).map_err(StartupError::ReadAuth)?;
|
||||
|
@ -22,6 +22,7 @@ fn generate_schema(type_count: usize) -> String {
|
||||
schema_str
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
pub fn bench_serde(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("schema_serde");
|
||||
for type_count in [100, 1000, 10000] {
|
||||
|
@ -10,6 +10,7 @@ use std::{
|
||||
use expect_test::expect_file;
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::print_stdout)]
|
||||
fn test_parser_for_schema(schema_path: &Path) -> Result<(), io::Error> {
|
||||
let schema = fs::read_to_string(schema_path)?;
|
||||
let expected_ast_path = schema_path.with_extension("ast.txt");
|
||||
@ -189,6 +190,7 @@ fn project_root() -> PathBuf {
|
||||
}
|
||||
|
||||
// Additional sanity checks to distinguish our error and success expectations:
|
||||
#[allow(clippy::print_stdout)]
|
||||
fn assert_is_err<T: std::fmt::Debug>(actual: &parser::Result<T>, path: &Path) {
|
||||
if actual.is_ok() {
|
||||
println!("erroneously successful parse: {actual:?}");
|
||||
@ -199,6 +201,7 @@ fn assert_is_err<T: std::fmt::Debug>(actual: &parser::Result<T>, path: &Path) {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
fn assert_is_ok<T: std::fmt::Debug>(actual: &parser::Result<T>, path: &Path) {
|
||||
if actual.is_err() {
|
||||
println!("error: {actual:?}");
|
||||
|
@ -209,10 +209,11 @@ fn check_titles(schema: &Schema, is_externally_tagged_enum_variant: bool) {
|
||||
.as_ref()
|
||||
.is_some_and(|metadata| metadata.title.is_some());
|
||||
|
||||
if should_have_title && !has_title {
|
||||
println!("{}", serde_json::to_string_pretty(schema).unwrap());
|
||||
panic!("Schema does not have a title present.")
|
||||
}
|
||||
assert!(
|
||||
!should_have_title || has_title,
|
||||
"Schema does not have a title present: {}",
|
||||
serde_json::to_string_pretty(schema).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,10 +233,12 @@ fn check_no_arbitrary_additional_properties(schema: &Schema, config: &JsonSchema
|
||||
.contains(&title.as_str())
|
||||
})
|
||||
});
|
||||
if has_arbitrary_additional_properties && !is_allowed {
|
||||
println!("{}", serde_json::to_string_pretty(schema).unwrap());
|
||||
panic!("Schema has arbitrary additional properties")
|
||||
}
|
||||
|
||||
assert!(
|
||||
!has_arbitrary_additional_properties || is_allowed,
|
||||
"Schema has arbitrary additional properties: {}",
|
||||
serde_json::to_string_pretty(schema).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
// just a dummy serialize test for now to visualize the output
|
||||
#[allow(clippy::print_stdout)]
|
||||
fn dummy_serialize() {
|
||||
/*
|
||||
* Consider we are serializing usage analytics for the following query
|
||||
|
@ -11,6 +11,7 @@ use std::{
|
||||
use hasura_authn_core::Role;
|
||||
use schema::{GDSNamespaceGetterAgnostic, GDSRoleNamespaceGetter};
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
pub fn main() {
|
||||
let mut metadata_string = String::new();
|
||||
let mut h = stdin();
|
||||
|
@ -460,6 +460,7 @@ mod tests {
|
||||
|
||||
use crate::{GDSNamespaceGetterAgnostic, GDSRoleNamespaceGetter};
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
fn make_sdl_from_metadata_file_for_role(path: &Path, role: &Role) -> String {
|
||||
println!("{path:#?}");
|
||||
let metadata_string = fs::read_to_string(path).unwrap();
|
||||
@ -474,6 +475,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
fn make_role_agnostic_sdl_from_metadata_file(path: &Path) -> String {
|
||||
println!("{path:#?}");
|
||||
let metadata_string = fs::read_to_string(path).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user