Skip to content

Incorrect indentation for comments in function calls #1108

@IndrajeetPatil

Description

@IndrajeetPatil

Actual

This produces a lint:

'gghistostats( 
  mtcars,
  wt,
  ggplot.component =
  # modify further with {ggplot2}
    list(
      theme(axis.text.x = element_text(angle = 90))
    )
)' -> code

styler::style_text(code)
#> gghistostats(
#>   mtcars,
#>   wt,
#>   ggplot.component =
#>   # modify further with {ggplot2}
#>     list(
#>       theme(axis.text.x = element_text(angle = 90))
#>     )
#> )

lintr::lint(text = code, linters = lintr::indentation_linter())
#> <text>:5:2: style: [indentation_linter] Indentation should be 4 spaces but is 2 spaces.
#>   # modify further with {ggplot2}
#>  ^~~

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

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 (2022-10-31)
#>  os       macOS Ventura 13.2.1
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Berlin
#>  date     2023-04-06
#>  pandoc   3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date (UTC) lib source
#>  backports      1.4.1      2021-12-13 [1] CRAN (R 4.2.0)
#>  callr          3.7.3      2022-11-02 [1] CRAN (R 4.2.0)
#>  cli            3.6.1      2023-03-23 [1] CRAN (R 4.2.2)
#>  crayon         1.5.2      2022-09-29 [1] CRAN (R 4.2.1)
#>  cyclocomp      1.1.0      2016-09-10 [1] CRAN (R 4.2.0)
#>  desc           1.4.2      2022-09-08 [1] CRAN (R 4.2.1)
#>  digest         0.6.31     2022-12-11 [1] CRAN (R 4.2.2)
#>  evaluate       0.20       2023-01-17 [1] CRAN (R 4.2.0)
#>  fastmap        1.1.1      2023-02-24 [1] CRAN (R 4.2.0)
#>  fs             1.6.1      2023-02-06 [1] CRAN (R 4.2.0)
#>  glue           1.6.2      2022-02-24 [1] CRAN (R 4.2.0)
#>  htmltools      0.5.5      2023-03-23 [1] CRAN (R 4.2.2)
#>  knitr          1.42       2023-01-25 [1] CRAN (R 4.2.2)
#>  lazyeval       0.2.2      2019-03-15 [1] CRAN (R 4.2.0)
#>  lifecycle      1.0.3      2022-10-07 [1] CRAN (R 4.2.1)
#>  lintr          3.0.2.9000 2023-04-04 [1] local
#>  magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.2.0)
#>  prettycode     1.1.0      2019-12-16 [1] CRAN (R 4.2.0)
#>  processx       3.8.0      2022-10-26 [1] CRAN (R 4.2.1)
#>  ps             1.7.4      2023-04-02 [1] CRAN (R 4.2.2)
#>  purrr          1.0.1      2023-01-10 [1] CRAN (R 4.2.2)
#>  R.cache        0.16.0     2022-07-21 [1] CRAN (R 4.2.0)
#>  R.methodsS3    1.8.2      2022-06-13 [1] CRAN (R 4.2.0)
#>  R.oo           1.25.0     2022-06-12 [1] CRAN (R 4.2.0)
#>  R.utils        2.12.2     2022-11-11 [1] CRAN (R 4.2.2)
#>  R6             2.5.1.9000 2022-10-27 [1] local
#>  remotes        2.4.2      2021-11-30 [1] CRAN (R 4.2.0)
#>  reprex         2.0.2      2022-08-17 [1] CRAN (R 4.2.1)
#>  rex            1.2.1      2021-11-26 [1] CRAN (R 4.2.0)
#>  rlang          1.1.0      2023-03-14 [1] CRAN (R 4.2.0)
#>  rmarkdown      2.21       2023-03-26 [1] CRAN (R 4.2.2)
#>  rprojroot      2.0.3      2022-04-02 [1] CRAN (R 4.2.0)
#>  rstudioapi     0.14       2022-08-22 [1] CRAN (R 4.2.1)
#>  sessioninfo    1.2.2      2021-12-06 [1] CRAN (R 4.2.0)
#>  styler         1.9.1      2023-04-05 [1] Github (r-lib/styler@db9bbed)
#>  vctrs          0.6.1      2023-03-22 [1] CRAN (R 4.2.0)
#>  withr          2.5.0      2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun           0.38       2023-03-24 [1] CRAN (R 4.2.2)
#>  xml2           1.3.3      2021-11-30 [1] CRAN (R 4.2.0)
#>  xmlparsedata   1.0.5      2021-03-06 [1] CRAN (R 4.2.0)
#>  yaml           2.3.7      2023-01-23 [1] CRAN (R 4.2.2)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Expected

styler::style_text(code)
#> gghistostats(
#>   mtcars,
#>   wt,
#>   ggplot.component =
#>     # modify further with {ggplot2}
#>     list(
#>       theme(axis.text.x = element_text(angle = 90))
#>     )
#> )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions