require-blank-line-before-return
WarningWarningWarningWarningSeparate the final return of a function or closure body from the statements above it, even when the body has two statements. if bodies and match arms are skipped.
fn build() -> Settings { let host = host(); let port = port(); return Settings { host, port };}fn query(request: Request) -> Response { let query = request.into_inner(); return execute(query);}fn build() -> Settings { let host = host(); let port = port(); return Settings { host, port };}fn query(request: Request) -> Response { let query = request.into_inner(); return execute(query);}fn status(result: Result<User, Error>) -> Result<User, Error> { return match result { Ok(user) => { notify(&user); return Ok(user); } Err(error) => Err(error), };}function build() { const host = getHost(); return { host };}function build() { const host = getHost(); return { host };}function run(ready: boolean) { if (ready) { prepare(); return true; } return false;}Settings build() { final host = getHost(); return Settings(host);}Settings build() { final host = getHost(); return Settings(host);}class A { int run() { int first = 1; return first; }}class A { int run() { int first = 1; return first; }}How to fix
Even a two-statement function or closure body needs a blank line before its final return. In nested blocks such as if bodies and match arms, the return can stay next to the statement it belongs to.
How to fix
Even a two-statement function or closure body needs a blank line before its final return. In nested blocks such as if bodies and match arms, the return can stay next to the statement it belongs to.
How to fix
Even a two-statement function or closure body needs a blank line before its final return. In nested blocks such as if bodies and match arms, the return can stay next to the statement it belongs to.
How to fix
Even a two-statement function or closure body needs a blank line before its final return. In nested blocks such as if bodies and match arms, the return can stay next to the statement it belongs to.