Skip to content

Incorrect "Place a space before left parenthesis, except in a function call." #508

Closed

Description

@bersbersbers

Hello, I believe this is still an issue:

x^(y + z)

lintr_2.0.1 still says

Place a space before left parenthesis, except in a function call.

Originally posted by @bersbersbers in #302 (comment)

Activity

  1. MichaelChirico commented on Oct 4, 2020

    @MichaelChirico
    Collaborator

    Is this still affecting you? I don't get that lint:

    writeLines('x^(y + z)', tmp <- tempfile())
    lintr::lint(tmp, lintr::spaces_left_parentheses_linter)
    
  2. bersbersbers commented on Oct 4, 2020

    @bersbersbers
    Author

    Yes, I do.

    R 3:

    Details
    R version 3.5.0 (2018-04-23) -- "Joy in Playing"
    Copyright (C) 2018 The R Foundation for Statistical Computing
    Platform: x86_64-suse-linux-gnu (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
      Natural language support but running in an English locale
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    [Previously saved workspace restored]
    
    > library(lintr)
    > sessionInfo()
    R version 3.5.0 (2018-04-23)
    Platform: x86_64-suse-linux-gnu (64-bit)
    Running under: openSUSE Leap 15.1
    
    Matrix products: default
    BLAS: /usr/lib64/R/lib/libRblas.so
    LAPACK: /usr/lib64/R/lib/libRlapack.so
    
    locale:
     [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
     [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
     [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
     [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
     [9] LC_ADDRESS=C               LC_TELEPHONE=C            
    [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] lintr_2.0.1
    
    loaded via a namespace (and not attached):
     [1] Rcpp_1.0.4.6      pillar_1.4.4      compiler_3.5.0    remotes_2.1.1    
     [5] prettyunits_1.1.1 tools_3.5.0       progress_1.2.2    zeallot_0.1.0    
     [9] lifecycle_0.2.0   tibble_3.0.1      gtable_0.3.0      gganimate_1.0.6  
    [13] pkgconfig_2.0.3   rlang_0.4.6       rex_1.2.0         cyclocomp_1.1.0  
    [17] xml2_1.3.2        withr_2.2.0       bayestestR_0.7.0  dplyr_0.8.5      
    [21] stringr_1.4.0     desc_1.2.0        vctrs_0.3.1       contfrac_1.1-12  
    [25] elliptic_1.4-0    hms_0.5.3         rprojroot_1.3-2   grid_3.5.0       
    [29] tidyselect_1.1.0  deSolve_1.28      glue_1.4.1        R6_2.4.1         
    [33] processx_3.4.2    gifski_0.8.6      callr_3.4.3       ggplot2_3.3.2    
    [37] purrr_0.3.4       tweenr_1.0.1      farver_2.0.3      magrittr_1.5     
    [41] backports_1.1.8   ps_1.3.3          scales_1.1.1      ellipsis_0.3.1   
    [45] MASS_7.3-51.6     assertthat_0.2.1  insight_0.8.5     colorspace_1.4-1 
    [49] stringi_1.4.6     lazyeval_0.2.2    munsell_0.5.0     crayon_1.3.4     
    [53] hypergeo_1.2-13  
    > writeLines('x^(y + z)', tmp <- tempfile())
    > lintr::lint(tmp, lintr::spaces_left_parentheses_linter)
    /tmp/Rtmp4uhMCL/file2bcb1e2181d:1:3: style: Place a space before left parenthesis, except in a function call.
    x^(y + z)
      ^
    

    R 4:

    Details
    R version 4.0.2 (2020-06-22) -- "Taking Off Again"
    Copyright (C) 2020 The R Foundation for Statistical Computing
    Platform: x86_64-pc-linux-gnu (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
      Natural language support but running in an English locale
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    [Previously saved workspace restored]
    
    > library(lintr)
    > sessionInfo()
    R version 4.0.2 (2020-06-22)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: openSUSE Leap 15.1
    
    Matrix products: default
    BLAS:   /home/bers/R-4.0.2/lib/libRblas.so
    LAPACK: /home/bers/R-4.0.2/lib/libRlapack.so
    
    locale:
     [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
     [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
     [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
     [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
     [9] LC_ADDRESS=C               LC_TELEPHONE=C            
    [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] lintr_2.0.1
    
    loaded via a namespace (and not attached):
     [1] Rcpp_1.0.5        pillar_1.4.6      compiler_4.0.2    remotes_2.1.1    
     [5] prettyunits_1.1.1 tools_4.0.2       progress_1.2.2    zeallot_0.1.0    
     [9] lifecycle_0.2.0   tibble_3.0.3      gtable_0.3.0      gganimate_1.0.6  
    [13] pkgconfig_2.0.3   rlang_0.4.7       rex_1.2.0         cyclocomp_1.1.0  
    [17] xml2_1.3.2        withr_2.2.0       bayestestR_0.7.0  dplyr_0.8.5      
    [21] stringr_1.4.0     desc_1.2.0        vctrs_0.3.2       contfrac_1.1-12  
    [25] elliptic_1.4-0    hms_0.5.3         rprojroot_1.3-2   grid_4.0.2       
    [29] tidyselect_1.1.0  deSolve_1.28      glue_1.4.1        R6_2.4.1         
    [33] processx_3.4.3    gifski_0.8.6      callr_3.4.3       ggplot2_3.3.2    
    [37] purrr_0.3.4       tweenr_1.0.1      farver_2.0.3      magrittr_1.5     
    [41] backports_1.1.8   ps_1.3.3          scales_1.1.1      ellipsis_0.3.1   
    [45] MASS_7.3-51.6     assertthat_0.2.1  insight_0.8.5     colorspace_1.4-1 
    [49] stringi_1.4.6     lazyeval_0.2.2    munsell_0.5.0     crayon_1.3.4     
    [53] hypergeo_1.2-13  
    > writeLines('x^(y + z)', tmp <- tempfile())
    > lintr::lint(tmp, lintr::spaces_left_parentheses_linter)
    /tmp/RtmppJqpht/file2c796083d93a:1:3: style: Place a space before left parenthesis, except in a function call.
    x^(y + z)
    

    R 4 after update.packages:

    Details
    R version 4.0.2 (2020-06-22) -- "Taking Off Again"
    Copyright (C) 2020 The R Foundation for Statistical Computing
    Platform: x86_64-pc-linux-gnu (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
      Natural language support but running in an English locale
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    > library(lintr)
    > sessionInfo()
    R version 4.0.2 (2020-06-22)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: openSUSE Leap 15.1
    
    Matrix products: default
    BLAS:   /home/bers/R-4.0.2/lib/libRblas.so
    LAPACK: /home/bers/R-4.0.2/lib/libRlapack.so
    
    locale:
     [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
     [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
     [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
     [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
     [9] LC_ADDRESS=C               LC_TELEPHONE=C            
    [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] lintr_2.0.1
    
    loaded via a namespace (and not attached):
     [1] ps_1.3.4         crayon_1.3.4     withr_2.3.0      rprojroot_1.3-2 
     [5] assertthat_0.2.1 R6_2.4.1         backports_1.1.10 lazyeval_0.2.2  
     [9] remotes_2.2.0    callr_3.4.4      rex_1.2.0        xml2_1.3.2      
    [13] cyclocomp_1.1.0  desc_1.2.0       tools_4.0.2      compiler_4.0.2  
    [17] processx_3.4.4  
    > writeLines("x^(y + z)", tmp <- tempfile())
    > lintr::lint(tmp)
    /tmp/RtmpUKAzTc/file149d766004cb:1:3: style: Place a space before left parenthesis, except in a function call.
    x^(y + z)
      ^ 
    
  3. AshesITR commented on Oct 5, 2020

    @AshesITR
    Collaborator
  4. added
    bug
    on Oct 5, 2020
  5. bersbersbers commented on Oct 10, 2020

    @bersbersbers
    Author

    Here's another example:

    a <- -(b)
    

    Place a space before left parenthesis, except in a function call.

    However, the style guide states:

    There are a few exceptions, which should never be surrounded by spaces:

    • The operators with high precedence: ::, :::, $, @, [, [[, ^, unary -, unary +, and :.

    The - in -(b) is a "unary -", right?

  6. MichaelChirico commented on Oct 12, 2020

    @MichaelChirico
    Collaborator

    Finally got to a machine where I could install dev easily. Reproduced:

    writeLines('x^(y + z)', tmp <- tempfile())
    lintr::lint(tmp, lintr::spaces_left_parentheses_linter)
    # /tmp/Rtmph7N5lN/file16dd635bfa31:1:3: style: Place a space before left parenthesis, except in a function call.
    # x^(y + z)
    
  7. added a commit that references this issue on Oct 26, 2020
  8. bersbersbers commented on Dec 1, 2020

    @bersbersbers
    Author

    Thanks - this works for me after devtools::install_github("https://github.com/jimhester/lintr")!

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