Skip to content

conjunct_test_linter: Allow to opt out of linting dplyr::filter() #2108

Closed

Description

@salim-b

#2077 added support to lint logical conjunctions inside dplyr::filter() calls. Quote:

Relatedly, dplyr::filter(DF, A & B) is the same as dplyr::filter(DF, A, B), but the latter will be more readable / easier to format for long conditions.

I respectfully disagree with the "latter will be more readable" part and would like to use conjunct_test_linter without linting dplyr::filter() calls. Would you be willing to introduce a flag like allow_inside_dplyr_filter to opt out of this behaviour?

Activity

  1. MichaelChirico commented on Sep 5, 2023

    @MichaelChirico
    Collaborator

    I think in that sentence the emphasis is on "for long conditions". We often see code like:

    DF |>
      filter(
        is_treatment &
          (expenditure - cost > 0) &
          group == "x"
      )

    In this case it's not very controversial that using , is better:

    DF |>
      filter(
        is_treatment,
        expenditure - cost > 0,
        group == "x"
      )

    It's more of a toss-up for simple cases, like A & B vs A, B.

    Anyway, happy to accept a PR. I would simply call such an argument allow_filter.

  2. salim-b commented on Sep 5, 2023

    @salim-b
    ContributorAuthor

    It's more of a toss-up for simple cases, like A & B vs A, B.

    Yeah, but I also think & is clearer than , in differentiating logical conjunctions from logical disjunctions (|).

    Anyway, happy to accept a PR. I would simply call such an argument allow_filter.

    Cool, see #2110.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted ❤️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions