Skip to content

Incorrent line number in "Missing terminal newline" from trailing_blank_lines_linter on .Rmd #1400

@russHyde

Description

@russHyde
text = '---
title: "Some file"
---

```{r}
abc = 123
```

```{r child="some-file.Rmd"}
```'
cat(text, file = "without-newline.Rmd")
cat(paste0(text, "\n"), file = "with-newline.Rmd")

Then try linting "without-newline.Rmd" and "with-newline.Rmd".

The former gives

without-newline.Rmd|6 col 10 warning| [trailing_blank_lines_linter] Missing terminal newline.

The latter is clean.

But note, that the missing-terminal-newline lint occurs on the line with the expression "abc = 123", rather than on the final line.

library(lintr)
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 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=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] lintr_3.0.0

loaded via a namespace (and not attached):
 [1] ps_1.7.0        crayon_1.5.1    withr_2.5.0     rprojroot_2.0.3
 [5] R6_2.5.1        cli_3.3.0       lazyeval_0.2.2  remotes_2.4.2  
 [9] callr_3.7.0     rex_1.2.1       xml2_1.3.3      cyclocomp_1.1.0
[13] desc_1.4.1      tools_4.1.3     parallel_4.1.3  compiler_4.1.3 
[17] processx_3.5.3

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions