Skip to content

Latest commit

 

History

History
51 lines (46 loc) · 1.2 KB

STYLE_GUIDE.md

File metadata and controls

51 lines (46 loc) · 1.2 KB

SPiFI Coding Conventions and Style

Groovy

Generally, we try to follow the Groovy Style Guide.

The following style constraints apply to SPiFI. In case of a conflict with the standard Groovy Style Guide, these rules take priority:

  • Add 3 empty lines prior to a class definition.
  • Indentation is 4 spaces.
  • Tabs...
    • are not allowed in leading whitespace.
    • discouraged in intermediate whitespace.
  • Remove all trailing whitespace.
  • Open/Close brackets (Closures) for blocks associated with a function call should be on a new line and left-aligned to the calling scope:
    if (A==1)
    {
    }
  • Instructions inside a closure should be indented by 4 spaces and begin on the next line after the opening bracket.
    if (A==1)
    {
        def B = 99
    }
    An exception can be made for closure parameters:
    S.each 
    { item ->
        println("- ${item}")
    }
  • Brackets can be opened on the same line as a Closure definition.
    Closure c = { /* single instruction */ }
    // or
    Closure c = {
        // multi line
        // closure
        // body
    }