Skip to content

brace_linter exception opening exception should apply when a comment precedes the lone brace, too #1434

Closed
@MichaelChirico

Description

@MichaelChirico

(nearly the same as #1433, and maybe both fixed at the same time, but filed separately since the cause is just different enough)

Compare:

lintr::lint('
switch(stat,
  o = {
    FUN <- FO
    bw <- 0.01
  },
  s = {
    FUN <- FS
    bw <- 0.005
  },
  {
    FUN <- FE
    bw <- 2
  }
)',
lintr::brace_linter())

vs

lintr::lint('
switch(stat,
  o = {
    FUN <- FO
    bw <- 0.01
  },
  s = {
    FUN <- FS
    bw <- 0.005
  },
  # else
  {
    FUN <- FE
    bw <- 2
  }
)',
lintr::brace_linter())
# <text>:12:3: style: [brace_linter] Opening curly braces should never go on their own line and should always be followed by a new line.
#   {
#   ^

The latter also shouldn't lint -- the # else comment is quite common/helpful, especially for long switch() statements.

Metadata

Metadata

Labels

false-positivecode that shouldn't lint, but does

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions