Skip to content

infix_spaces_linter lacks a way to specify different rules for different = (EQ_ASSIGN, EQ_SUB, and EQ_FORMALS) #1977

Closed
@MichaelChirico

Description

@MichaelChirico

Some authors (e.g. data.table) apply different rules for different =, for example:

f = function(a=1) a
f(a=2)

Specifically, EQ_SUB and EQ_FORMALS should not have surrounding spaces, but EQ_ASSIGN should.

Currently, exclude_operators only supports string inputs, so this type of node-level differentiation is impossible.

There are two options:

(1) Allow specifying node names in exclude_operators=. exclude_operators = c("EQ_SUB", "EQ_FORMALS") is unambiguously a parse_tag. The advantage is a simplified user interface, the disadvantage is overloading.
(2) Add a new argument exclude_parse_tags=, which will match against lintr:::infix_metadata$parse_tag instead of lintr:::infix_metadata$string_value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions