Skip to content

Instantly share code, notes, and snippets.

@olafurpg
Created June 21, 2016 06:46
Show Gist options
  • Save olafurpg/6543437bb03071c53bb1a74dc2122472 to your computer and use it in GitHub Desktop.
Save olafurpg/6543437bb03071c53bb1a74dc2122472 to your computer and use it in GitHub Desktop.
// Column 80 |
object a {
Ok(
Json.obj("api" -> Json.obj("current" -> api.currentVersion,
"olds" -> api.oldVersions.map { old =>
Json.obj("version" -> old.version,
"deprecatedAt" -> old.deprecatedAt,
"unsupportedAt" -> old.unsupportedAt)
}))) as JSON
}
@enlait
Copy link

enlait commented Jun 21, 2016

While I think it's kinda messy no matter how you look at it, and I do not usually use vertical aligning by tokens, if I were to, I'd probably go for something like that:

// Column 80                                                                   |
object a {
  Ok(
    Json.obj("api" -> Json.obj("current" -> api.currentVersion,
                               "olds"    -> api.oldVersions.map { old =>
                               Json.obj("version"       -> old.version,
                                        "deprecatedAt"  -> old.deprecatedAt,
                                        "unsupportedAt" -> old.unsupportedAt)
                               }))) as JSON
}

Not sure about not aligning by a vertical parenthesis on line 4... but most importantly, the contents of a block (lines 6-9) should not be shifted to the left from the line 5 that opens that block.

Maybe even like this:

// Column 80                                                                   |
object a {
  Ok(
    Json.obj("api" -> Json.obj("current" -> api.currentVersion,
                               "olds"    -> api.oldVersions.map { old =>
                                              Json.obj("version"       -> old.version,
                                                       "deprecatedAt"  -> old.deprecatedAt,
                                                       "unsupportedAt" -> old.unsupportedAt)
                                            }))) as JSON
}

but this is a bad use of horizontal space and can get out of hand... immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment