Lintr bot duplicate comments

travis-ci

#1

I get lintr-bot comments in triplicate on PRs, presumably from tests running on travis on three R builds. (example) Is there an easy way to fix this?

test-lint.R:

context("lints")
test_that("Package is lint free", {
  skip_on_appveyor()
  lintr::expect_lint_free(
    linters = lintr::with_defaults(camel_case_linter = NULL,
                                   line_length_linter = NULL,
                                   object_usage_linter = NULL)
  )
})

.travis.yml:

language: r
sudo: false
cache: packages
dist: trusty

...

env:  
r:
  - oldrel
  - release
  - devel
matrix:
  allow_failures:
  - r: devel

r_packages:
  - covr

addons:
  apt:
    packages:
      - libnlopt-dev

after_success:
  - Rscript -e 'covr::codecov()'


#2

I think you will need to restrict running lintr to running only on one build. Generally I now recommend running lintr separately, outside of the package tests. You can run it with something like

before_script:
  R -e 'lintr::lint_package()'

#3

Thanks @jimhester. Since .lintr is in .Rbuildignore, settings there don't get picked up on Travis. Is your suggested way to specify options in the lint_package call in .travis.yml?


#4

.lintr is still available on travis as long as you don't run it from the built package, e.g. in the tests. The working directory is just a git clone of the repo, so it has all commited files.


#5

Oh, that's helpful on the Travis environment, thanks. For what it's worth, this ended up feeling like more trouble than it was worth -- was getting repeated comments for each commit within a PR and object_length_linter (which I don't adjust anywhere) was behaving differently in and out of testthat -- so I fell back to running tests in testthat on travis and just turning lintr-bot off. Thanks for your help, and for the tool.