Skip to content

COR101 misleading-inline-if-continuation ​

warning enabled by default

A one-line if continues its action on the next line.

Why ​

if (c) & followed by an indented statement on the next line looks like a block if. Whoever adds a second indented statement below expects it to be conditional too, and it is not. Use an if ... then ... end if block when the action does not fit on the line.

Reported ​

fortran
if (verbose) &
  call report(state)

Preferred ​

fortran
if (verbose) then
  call report(state)
end if

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[COR101] <why this occurrence is fine>

For the whole project, ignore = COR101 in the fobos [lint] section.

Equivalent ​

Fortitude rule C152 (see Lint Rules).