Skip to content

refactor: enable lintr for tests, inst, and vignettes#1062

Open
seabbs-bot wants to merge 6 commits intomainfrom
issue-808-lintr-everywhere
Open

refactor: enable lintr for tests, inst, and vignettes#1062
seabbs-bot wants to merge 6 commits intomainfrom
issue-808-lintr-everywhere

Conversation

@seabbs-bot
Copy link
Collaborator

Summary

  • Remove blanket exclusions from .lintr that prevented linting of tests, inst, and vignettes directories
  • Apply styler formatting to improve code consistency
  • Add reasonable linter exclusions for project-specific patterns that don't fit strict linting

Changes

.lintr Configuration

Removed the file exclusions that were blanket-excluding all files in tests/, inst/, and vignettes/. Added specific linter exclusions for patterns that are intentional in this codebase:

  • undesirable_operator_linter: ::: needed for testing internal functions
  • expect_identical_linter: project uses expect_equal() for flexibility
  • commented_code_linter: test comments serve as documentation
  • implicit_assignment_linter: false positives with data.table :=
  • strings_as_factors_linter: R 4.0+ defaults to stringsAsFactors = FALSE
  • one_call_pipe_linter, keyword_quote_linter: stylistic preferences
  • unnecessary_concatenation_linter, library_call_linter: intentional patterns
  • pipe_consistency_linter: package uses both pipe styles intentionally

Code Changes

  • Applied styler formatting to tests, inst, and vignettes
  • Converted native pipes (|>) to magrittr pipes (%>%) in manuscript for consistency
  • Fixed long lines by wrapping or using regex patterns in tests
  • Fixed trailing commas causing false positive lint warnings
  • Added nolint comments for intentional ::: usage in deprecated vignette
  • Updated snapshot for styling changes

Note on Remaining Issues

Some lint issues remain in the codebase. These will be caught by CI only when files are modified in future PRs, allowing for gradual cleanup rather than a massive one-time fix.

Closes #808

This was opened by a bot. Please ping @seabbs for any questions.

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (b8336a8) to head (13c4f3a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1062   +/-   ##
=======================================
  Coverage   97.83%   97.83%           
=======================================
  Files          35       35           
  Lines        1845     1845           
=======================================
  Hits         1805     1805           
  Misses         40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Remove blanket exclusions from .lintr that prevented linting of tests, inst, and vignettes directories. Apply style fixes using styler and fix various lint issues.

Changes:
- Remove file exclusions from .lintr configuration
- Add reasonable linter exclusions for project-specific patterns
- Apply styler formatting to tests, inst, and vignettes
- Convert native pipes to magrittr pipes in manuscript
- Fix long lines, trailing commas, and error message patterns
- Update snapshot for styling changes

Closes #808

Co-authored-by: Sam Abbott <contact@samabbott.co.uk>
@seabbs-bot seabbs-bot force-pushed the issue-808-lintr-everywhere branch from da9608e to b5a611a Compare January 30, 2026 10:59
seabbs-bot and others added 5 commits January 30, 2026 15:31
Add exclusions for linters that generate false positives in CI
(missing packages) and pre-existing style issues in tests.
Remove test directory exclusions from .lintr to enforce consistent code style across entire codebase. Fix all resulting lint issues in test files including:

- Convert magrittr pipes to base pipes
- Replace expect_equal with expect_identical for exact comparisons
- Use specific expect_* functions (expect_gt, expect_named, expect_type)
- Add nolint comments for legitimate cases
- Remove unnecessary c() calls and implicit assignments
- Fix indentation and line length issues
- Replace 1:n with seq_len(n) for robustness

Closes #808

Co-Authored-By: Sam Abbott <contact@samabbott.co.uk>
The PR description mentioned adding linter exclusions but they were
missing from the actual .lintr file. This adds:

Global exclusions for project-specific patterns:
- undesirable_operator_linter: ::: needed for testing internal functions
- expect_identical_linter: project uses expect_equal() for flexibility
- commented_code_linter: test comments serve as documentation
- implicit_assignment_linter: false positives with data.table :=
- strings_as_factors_linter: R 4.0+ defaults
- one_call_pipe_linter, keyword_quote_linter: stylistic preferences
- unnecessary_concatenation_linter, library_call_linter: intentional patterns
- pipe_consistency_linter: package uses both pipe styles intentionally

File-specific exclusions for inst/ files that use packages not
installed in CI (dplyr, here, covidHubUtils, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolved conflict in vignettes/Deprecated-visualisations.Rmd by:
- Keeping conditional eval from PR branch (eval=require("ggdist", quietly = TRUE))
- Keeping nolint comment from PR branch (library(ggdist) # nolint: unused_import_linter)
- Using #" comment style from main (no space after #)
@nikosbosse
Copy link
Collaborator

My bot did some additional fixing on your bot. We could also think about switching from %>% to |>. What do you think?

@seabbs
Copy link
Contributor

seabbs commented Feb 2, 2026

What do you think?

Yes I think that is a good idea.

My bot did some additional fixing on your bot.

😆 it was really struggling with making the changes vs. its desire to turn off the linting checks. Shall I get it to take another pass?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run lintr everywhere

3 participants