Skip to content

Skip switch() and other calls by default in unnecessary_nesting_linter() #2334

Description

@MichaelChirico

Originally posted by @AshesITR in #2302 (comment)

Test case for switch():

test_that("unnecessary_nesting_linter skips one-expression switch statements", {
  expect_lint(
    trim_some("
      switch(x,
        a = {
          do_a()
        },
        b = {
          do_b()
        }
      )
    "),
    NULL,
    unnecessary_nesting_linter()
  )
})

Hint at implementation:

or self::expr/SYMBOL_FUNCTION_CALL[text() = 'switch']

See also #2326

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions