lintr icon indicating copy to clipboard operation
lintr copied to clipboard

How to apply lintr to package, linting not working (?

Open latot opened this issue 1 year ago • 4 comments

Hi all, I has been using lintr from some months, is great, seems there is some changes but I notice something really weird, I uses this as the doc says to enable the linting and check it:

# in a package:
lintr::use_lintr(type = "tidyverse")
usethis::use_github_action("lint")
lintr::lint_package()

Before, when there was a warning, the linting failed in the github tests so we can fix it, but for some reason, now the warnings of lintr does not fail, all tests pass fine, but when we check the linting test, there is warnings D:

Maybe the workflow of lint need an update? in that case would be nice to have a version 2 with it.

Thx!

latot avatar Oct 13 '22 14:10 latot

Hi @latot, can you share more details, for example, the .yml of your GHA (is it GHA)?

please also check this package's own lint workflows for inspiration.

MichaelChirico avatar Oct 13 '22 15:10 MichaelChirico

Okis!, seems I'm using the same as this project, don't know why the warnings pass D:

Yaml!

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

name: lint

jobs:
  lint:
    runs-on: ubuntu-latest
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2

      - uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::lintr, local::.
          needs: lint

      - name: Lint
        run: lintr::lint_package()
        shell: Rscript {0}

Note: Why opening the issue here? because, the idea of use usethis to set up the linting, is to be ready just with that command, not start tweaking it to do it works.

latot avatar Oct 13 '22 15:10 latot

please follow this one instead:

https://github.com/r-lib/lintr/blob/4b37029f989629287e910fa3aba46ab15d1975cb/.github/workflows/lint-changed-files.yaml

MichaelChirico avatar Oct 13 '22 15:10 MichaelChirico

I wish this would be merged soon. Because then users can just do:

usethis::use_github_action("lint-changed-files")

IndrajeetPatil avatar Oct 13 '22 20:10 IndrajeetPatil