Skip to content

Commit 72bf308

Browse files
committed
verify: Simplify nested if statements
Simplify and put the positive bool first and the negative second. E.g `if this && !that` Because it reads a bit easier. Internal change only, no logic change. Clears a clippy warning.
1 parent dd27d09 commit 72bf308

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

verify/src/main.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,13 @@ fn verify_status(version: Version, test_output: Option<&String>) -> Result<()> {
135135
let out =
136136
Method::from_name(version, &method.name).expect("guaranteed by methods_and_status()");
137137

138-
if !versioned::requires_type(version, &method.name)? {
139-
if versioned::type_exists(version, &method.name)? {
140-
eprintln!("return type found but method is omitted or TODO: {}", output_method(out));
141-
}
142-
}
143-
if !model::requires_type(version, &method.name)? {
144-
if model::type_exists(version, &method.name)? {
145-
eprintln!("model type found but method is omitted or TODO: {}", output_method(out));
146-
}
138+
if versioned::type_exists(version, &method.name)? && !versioned::requires_type(version, &method.name)? {
139+
eprintln!("return type found but method is omitted or TODO: {}", output_method(out));
147140
}
148141

142+
if model::type_exists(version, &method.name)? && !model::requires_type(version, &method.name)? {
143+
eprintln!("model type found but method is omitted or TODO: {}", output_method(out));
144+
}
149145
}
150146
}
151147
}
@@ -156,19 +152,14 @@ fn verify_status(version: Version, test_output: Option<&String>) -> Result<()> {
156152
fn check_types_exist_if_required(version: Version, method_name: &str) -> Result<()> {
157153
let out = Method::from_name(version, method_name).expect("guaranteed by methods_and_status()");
158154

159-
if versioned::requires_type(version, method_name)? {
160-
if !versioned::type_exists(version, method_name)? {
161-
eprintln!("missing return type: {}", output_method(out));
162-
}
155+
if versioned::requires_type(version, method_name)? && !versioned::type_exists(version, method_name)? {
156+
eprintln!("missing return type: {}", output_method(out));
163157
}
164-
if model::requires_type(version, method_name)? {
165-
if !model::type_exists(version, method_name)? {
166-
eprintln!("missing model type: {}", output_method(out));
167-
}
168-
} else {
169-
if model::type_exists(version, method_name)? {
170-
eprintln!("found model type when none expected: {}", output_method(out));
171-
}
158+
if model::requires_type(version, method_name)? && !model::type_exists(version, method_name)? {
159+
eprintln!("missing model type: {}", output_method(out));
160+
}
161+
if model::type_exists(version, method_name)? && !model::requires_type(version, method_name)? {
162+
eprintln!("found model type when none expected: {}", output_method(out));
172163
}
173164
Ok(())
174165
}

0 commit comments

Comments
 (0)