darwin-eu-dev / PaRe

PaRe (Package Reviewer) is the successor of the DependencyReviewer package.
https://darwin-eu-dev.github.io/PaRe/
3 stars 3 forks source link

Error with makeReport: object 'lineEnd' not found #39

Closed ablack3 closed 1 year ago

ablack3 commented 1 year ago

Hi @mvankessel-EMC I think this is a bug. Here is my reprex. Comes pretty much exactly from the example code.

fetchedRepo <- tryCatch(
  {
    # Set dir to clone repository to.
    tempDir <- tempdir()
    pathToRepo <- file.path(tempDir, "glue")

    # Clone repo
    git2r::clone(
      url = "https://github.com/OHDSI/Eunomia.git",
      local_path = pathToRepo
    )

    # Create instance of Repository object.
    repo <- PaRe::Repository$new(path = pathToRepo)

    # Set fetchedRepo to TRUE if all goes well.
    TRUE
  },
  error = function(e) {
    # Set fetchedRepo to FALSE if an error is encountered.
    FALSE
  },
  warning = function(w) {
    # Set fetchedRepo to FALSE if a warning is encountered.
    FALSE
  }
)
#> cloning into '/var/folders/xx/01v98b6546ldnm1rg1_bvk000000gn/T//RtmpsKCpSp/glue'...
#> Receiving objects:   1% (10/903),   15 kb
#> Receiving objects:  11% (100/903),   64 kb
#> Receiving objects:  21% (190/903), 5001 kb
#> Receiving objects:  31% (280/903), 12734 kb
#> Receiving objects:  41% (371/903), 28174 kb
#> Receiving objects:  51% (461/903), 33234 kb
#> Receiving objects:  61% (551/903), 38318 kb
#> Receiving objects:  71% (642/903), 42568 kb
#> Receiving objects:  81% (732/903), 46178 kb
#> Receiving objects:  91% (822/903), 48631 kb
#> Receiving objects: 100% (903/903), 48722 kb, done.

if (fetchedRepo) {
  # Run makeReport on the Repository object.
  PaRe::makeReport(repo = repo, outputFile = tempfile())
}
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout
#> Linking to ImageMagick 6.9.12.3
#> Enabled features: cairo, fontconfig, freetype, heic, lcms, pango, raw, rsvg, webp
#> Disabled features: fftw, ghostscript, x11
#> processing file: report.Rmd
#> 
#> Quitting from lines 31-35 [getDefinedFunctionsPkg] (report.Rmd)
#> Error in `dplyr::mutate()`:
#> ℹ In argument: `size = lineEnd - lineStart + 1`.
#> Caused by error:
#> ! object 'lineEnd' not found
#> Backtrace:
#>      ▆
#>   1. ├─defFuns %>% dplyr::mutate(size = lineEnd - lineStart + 1)
#>   2. ├─dplyr::mutate(., size = lineEnd - lineStart + 1)
#>   3. ├─dplyr:::mutate.data.frame(., size = lineEnd - lineStart + 1)
#>   4. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
#>   5. │   ├─base::withCallingHandlers(...)
#>   6. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
#>   7. │     └─mask$eval_all_mutate(quo)
#>   8. │       └─dplyr (local) eval()
#>   9. └─base::.handleSimpleError(...)
#>  10.   └─dplyr (local) h(simpleError(msg, call))
#>  11.     └─rlang::abort(message, class = error_class, parent = parent, call = error_call)

sessionInfo()
#> R version 4.2.2 (2022-10-31)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur ... 10.16
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] knitr_1.43    cowplot_1.1.1 withr_2.5.0   magick_2.7.4  DT_0.28      
#> [6] ggraph_2.1.0  plotly_4.10.2 ggplot2_3.4.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] fs_1.6.2           RColorBrewer_1.1-3 httr_1.4.6         rprojroot_2.0.3   
#>  [5] R.cache_0.16.0     DiagrammeRsvg_0.1  tools_4.2.2        backports_1.4.1   
#>  [9] bslib_0.5.0        utf8_1.2.3         R6_2.5.1           lazyeval_0.2.2    
#> [13] colorspace_2.1-0   tidyselect_1.2.0   gridExtra_2.3      processx_3.8.1    
#> [17] curl_5.0.1         compiler_4.2.2     git2r_0.32.0       cli_3.6.1         
#> [21] xml2_1.3.4         desc_1.4.2         sass_0.4.6         scales_1.2.1      
#> [25] checkmate_2.2.0    callr_3.7.3        stringr_1.5.0      digest_0.6.31     
#> [29] rmarkdown_2.22     R.utils_2.12.2     lintr_3.0.2        pkgconfig_2.0.3   
#> [33] htmltools_0.5.5    styler_1.10.1      fastmap_1.1.1      highr_0.10        
#> [37] htmlwidgets_1.6.2  rlang_1.1.1        rstudioapi_0.14    visNetwork_2.1.2  
#> [41] jquerylib_0.1.4    generics_0.1.3     farver_2.1.1       jsonlite_1.8.5    
#> [45] dplyr_1.1.2        R.oo_1.25.0        magrittr_2.0.3     Rcpp_1.0.10       
#> [49] munsell_0.5.0      fansi_1.0.4        viridis_0.6.3      lifecycle_1.0.3   
#> [53] R.methodsS3_1.8.2  stringi_1.7.12     yaml_2.3.7         MASS_7.3-58.1     
#> [57] grid_4.2.2         ggrepel_0.9.3      crayon_1.5.2       graphlayouts_1.0.0
#> [61] ps_1.7.5           pillar_1.9.0       igraph_1.4.3       pak_0.5.1         
#> [65] PaRe_0.1.9         reprex_2.0.2       glue_1.6.2         evaluate_0.21     
#> [69] rex_1.2.1          V8_4.3.0           data.table_1.14.8  remotes_2.4.2     
#> [73] vctrs_0.6.2        tweenr_2.0.2       gtable_0.3.3       purrr_1.0.1       
#> [77] polyclip_1.10-4    tidyr_1.3.0        cachem_1.0.8       xfun_0.39         
#> [81] ggforce_0.4.1      tidygraph_1.2.3    rsvg_2.4.0         cyclocomp_1.1.0   
#> [85] viridisLite_0.4.2  tibble_3.2.1       DiagrammeR_1.0.10

Created on 2023-06-15 with reprex v2.0.2

mvankessel-EMC commented 1 year ago

Hi @ablack3 thanks for the report. Could you try installing the dev branch, as I think I caught this bug earlier this week.

remotes::install_github("darwin-eu-dev@dev")

I'd like to release that version (0.1.10) either later today or upcoming Monday to CRAN.

Also I'd like to point out that you are setting pathToRepo like this:

tempDir <- tempdir()
pathToRepo <- file.path(tempDir, "glue")

But you are cloning the Eunomia repository into that glue folder.

repo <- PaRe::Repository$new(path = pathToRepo)

Let me know if that helped!

edward-burn commented 1 year ago

@mvankessel-EMC I get this when try to generate the article for PatientProfiles (not sure if this relates to the same issue or not) incomplete final line found on 'D:\github\patientProfiles\PatientProfiles/R/sysdata.rda'

mvankessel-EMC commented 1 year ago

@mvankessel-EMC I get this when try to generate the article for PatientProfiles (not sure if this relates to the same issue or not) incomplete final line found on 'D:\github\patientProfiles\PatientProfiles/R/sysdata.rda'

The incomplete final line found on 'D:\github\patientProfiles\PatientProfiles/R/sysdata.rda' is usually not something to worry about. If this happens in R-files for instance, you can add a blank line at the bottom, which will resolve this.

It it good that you brought this up though, as rda-files should not be picked up. I will update the matching pattern for this.

mvankessel-EMC commented 1 year ago

So for @ablack3 an rmd-file as included in the ./R/ folder, which cause the problem, for @edward-burn an rda-file. I've included a pattern that should ignore such files under the ./R/ folder, using \\.[Rr]$. In adfd8af.