Skip to content

Missing object_usage_linter due to line break #507

Closed

Description

@bersbersbers
foo <- function() {
    unknown_function(1)

    unknown_function(
        1
    )

    unknown_function(1)
}

I get this in VS Code, while in my opinion, the middle call should also be detected.

image
image

Activity

  1. added
    bug
    on Dec 9, 2020
  2. infotroph commented on Feb 15, 2021

    @infotroph
    Contributor

    A variant of this that bit me today: multiline conditionals.

    foo <- function() {
    
        # warns
        if (unknown_function()) NULL 
    
        # does not warn
        if (unknown_function()) {
        	NULL
        }
    
    }
    
  3. AshesITR commented on Feb 15, 2021

    @AshesITR
    Collaborator

    Thanks for reporting.
    The issue is in parse_check_usage when multiline warnings are issued:

    foo <- function() {
    
        # warns
        if (unknown_function()) NULL 
    
        # does not warn
        if (unknown_function()) {
            NULL
        }
    
    }
    
    codetools::checkUsage(foo)
    #> <anonymous>: no visible global function definition for 'unknown_function' (<text>:4)
    #> <anonymous>: no visible global function definition for 'unknown_function' (<text>:7-9)
    lintr:::parse_check_usage(foo)
    #>                                                        message             name
    #> 1 no visible global function definition for 'unknown_function' unknown_function
    #> 2                                                         <NA>             <NA>
    #>     path line_number
    #> 1 <text>           4
    #> 2   <NA>        <NA>

    Created on 2021-02-15 by the reprex package (v1.0.0)

  4. added a commit that references this issue on Feb 15, 2021
    9d7e75b
  5. added a commit that references this issue on Feb 18, 2021
    b1d4d0d
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions