Skip to content

Files

Latest commit

 

History

History
26 lines (16 loc) · 854 Bytes

ProcedureDeclaration.md

File metadata and controls

26 lines (16 loc) · 854 Bytes

Pattern: Missing = for procedure declaration

Issue: -

Description

A procedure style declaration can cause confusion - the developer may have simply forgotten to add a =, and now their method returns Unit rather than the inferred type:

def foo() { println("hello"); 5 }
def foo() = { println("hello"); 5 }

This rule raises a warning with the first line. To fix it, use an explicit return type, or add a = before the body.

Example configuration

<check enabled="true" class="org.scalastyle.scalariform.ProcedureDeclarationChecker" level="warning"/>