Skip to content

flagging commented arguments of a function being tested #386

Closed

Description

@IndrajeetPatil

If a line of code is commented, then lintr produces a lint of type

Commented code should be removed.

Example of this would be the following line of code-

# testthat::expect_equal(broom_df1$p.value, tidy_df1$p.value, tolerance = 0.001)

Does it also make sense to produce a lint of type

Commented arguments should be removed.

For example, here the second argument is commented out-

 d <- t.test(
        x = dplyr::starwars$height,
       # var.equal = TRUE,
        conf.level = .99,
        mu = 175
      )

testthat::expect_equal(d$statistic[[1]], -0.1661693, tolerance = 0.001)

This can typically happen when interactively writing tests and it will be nice for lintr to highlight such vestiges.

Activity

  1. jimhester commented on Sep 24, 2019

    @jimhester
    Member

    The issue is it is harder to determine if a line is an argument, particularly without introducing false positives.

    I don't have the time to spend on it, but if you or someone else wants to try implementing a PR for it that addressed the detection and false positive issues above I would review it.

  2. added
    feature
    help wanted ❤️
    on Sep 24, 2019
  3. AshesITR commented on Jun 19, 2022

    @AshesITR
    Collaborator

    Maybe we could extend commented code linter to also lint if it encounters a comment with a trailing comma whose preceding text is parsable().

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

    featurehelp wanted ❤️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions