FlowscopeDocs

P026

ternary broken before `?` or `:`

Severity Error

A line ends a statement as soon as the expression on it is complete. If the next line starts with ? or :, the previous line has already been taken as a whole statement and the leftover operator cannot be parsed.

Break long ternaries after the operator: end the line with ? or : and continue on the next line.

Failing example

Flowscope Script
script "Delta tint"
data vd = subscribe(data.vd)
pane p = pane(title: "Delta", height: 0.25)
plot delta = plot.columns(title: "Delta", on: p)
on vd.close {
  let d = vd.close ?? 0.0
  let tint = d >= 0.0
    ? color.bull
    : color.bear
  delta.plot(d, color: tint)
}

Fixed example

Flowscope Script
script "Delta tint"
data vd = subscribe(data.vd)
pane p = pane(title: "Delta", height: 0.25)
plot delta = plot.columns(title: "Delta", on: p)
on vd.close {
  let d = vd.close ?? 0.0
  let tint = d >= 0.0 ?
    color.bull :
    color.bear
  delta.plot(d, color: tint)
}