Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message not helpful when starts do not match ends of exclusion parts #860

Closed
danielinteractive opened this issue Sep 16, 2021 · 5 comments · Fixed by #865
Closed

Comments

@danielinteractive
Copy link
Contributor

danielinteractive commented Sep 16, 2021

Reprex:

  • Put the following in test.R:
#nolint start

c(1,2)
  • Run lintr:::addin_lint()
  • Note: It is important that 1) there is a start but not an end (or vice versa) and 2) there is an actual lintr problem (here no space after the comma)

Observation:
[...]/test.R has 1 starts but only 0 ends!

Problem:
This error message is not really helpful, especially when the file is large. It does not mention the line numbers of the start lines and that this is about the #nolint starts and ends.

Proposal:
Give more information in the error message (line numbers, mention #nolint). Currently the function has:

      stop(file, " has ", length(starts), " starts but only ", 
        length(ends), " ends!")

Session Info:

R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C               LC_TIME=de_CH.UTF-8       
 [4] LC_COLLATE=de_DE.UTF-8     LC_MONETARY=de_CH.UTF-8    LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_CH.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] ps_1.6.0           crayon_1.4.1       withr_2.4.2        rprojroot_2.0.2    R6_2.5.1          
 [6] magrittr_2.0.1     stringi_1.7.4      lazyeval_0.2.2     remotes_2.4.0      rstudioapi_0.13   
[11] callr_3.7.0        rex_1.2.0          xml2_1.3.2         cyclocomp_1.1.0    desc_1.3.0        
[16] tools_4.1.1        stringr_1.4.0      xfun_0.25          lintr_2.0.1        compiler_4.1.1    
[21] processx_3.5.2     xmlparsedata_1.0.5 knitr_1.33   

Thanks for considering :-)

@MichaelChirico
Copy link
Collaborator

MichaelChirico commented Sep 16, 2021 via email

@danielinteractive
Copy link
Contributor Author

Thanks @MichaelChirico - just tried this with the devel version and it gives the same. So it is not yet fixed it seems.

@MichaelChirico
Copy link
Collaborator

Could you share your new session info? I just tried myself and got the following more helpful error:

 Error in FUN(X[[i]], ...) : 
  /home/michael/github/lintr/R/test.R has 1 range start but only 0 range ends for exclusion from linting! 

@danielinteractive
Copy link
Contributor Author

@MichaelChirico Yes, I now get the slightly better error message that you quote too. But that could be much better (especially for large files) if we would quote the line numbers instead of just counting the starts and ends. Would you like me to propose this in a PR?

@MichaelChirico
Copy link
Collaborator

sure! improved error messages are always welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants