require-blank-line-before-control-flow
WarningWarningWarningWarningLeave a blank line before a multi-line if, loop, match, switch or try, even when it checks the value declared on the line above. The rule skips one-line guards in Dart and Java.
fn run() -> Result<()> { let relation = find()?; if relation.is_some() { return Err(Error::BadRequest); } return Ok(());}fn run(items: &[Item]) { let total = items.len(); for item in items { process(item, total); }}fn run() -> Result<()> { let user = load()?; if user.email == email { return Err(Error::BadRequest); } return Ok(());}fn run() { // Comments above a block are handled by require-blank-line-before-comment if ready { start(); }}function parse(output: string) { const parsed: unknown = JSON.parse(output); if (!Array.isArray(parsed)) throw new Error("Unexpected output"); return parsed;}function run(items: Item[]) { const total = items.length; for (const item of items) { process(item, total); }}function parse(output: string) { const parsed: unknown = JSON.parse(output); if (!Array.isArray(parsed)) throw new Error("Unexpected output"); return parsed;}void run() { final count = children.length; if (count == 1) { layout(count); }}void run(int index) { final value = load(); if (value == null) return; save(value);}void run() { final count = children.length; if (count == 1) { layout(count); }}class A { void run() { int count = load(); if (count == 1) { layout(count); } }}class A { void run() { int count = load(); if (count == 1) { layout(count); } }}How to fix
A multi-line if, match, for, while or loop starts a new group even when it checks the value declared on the line above.
The check reads the enclosing block's text because the syntax tree omits blank lines. If the block has several violations of this rule, the report can land on a neighboring node.
How to fix
A multi-line if, for, while, do, switch or try starts a new group even when it checks the value declared on the line above.
The check reads the enclosing block's text because the syntax tree omits blank lines. If the block has several violations of this rule, the report can land on a neighboring node.
How to fix
A multi-line if, for, while, do, switch or try starts a new group even when it checks the value declared on the line above. One-line guards such as if (index < 0) return; may stay next to the line they check.
The check reads the enclosing block's text because the syntax tree omits blank lines. If the block has several violations of this rule, the report can land on a neighboring node.
How to fix
A multi-line if, for, while, do, switch or try starts a new group even when it checks the value declared on the line above. One-line guards such as if (index < 0) return; may stay next to the line they check.
The check reads the enclosing block's text because the syntax tree omits blank lines. If the block has several violations of this rule, the report can land on a neighboring node.