Skip to contentSlop Block

require-blank-line-before-control-flow

Warning

Leave 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() {Leave a blank line before this block		return Err(Error::BadRequest);	}	return Ok(());}
fn run(items: &[Item]) {	let total = items.len();	for item in items {Leave a blank line before this block		process(item, total);	}}
// ast-grep-ignore: require-blank-line-before-control-flow-rust

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.