Skip to content

lint(text=) finds local settings again #2863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Jun 21, 2025

Closes #2847, cc @bastistician

Not the biggest fan of the new parse_settings=FALSE usages, open to ideas about what needs to be improved here...

PS, I originally pushed this directly to main by mistake as b548c78; reverted as dc7a612 to put this through normal review

Copy link

codecov bot commented Jun 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.26%. Comparing base (afb363c) to head (1ba8f42).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2863   +/-   ##
=======================================
  Coverage   99.26%   99.26%           
=======================================
  Files         127      127           
  Lines        7092     7092           
=======================================
  Hits         7040     7040           
  Misses         52       52           

☔ 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.

@MichaelChirico
Copy link
Collaborator Author

Hm, I think this is having an interaction with the lack of {cyclocomp}. IINM package examples of lint(text=.) are trying to use our ./.lintr config, which requires having {cyclocomp}. Testing if 159234d works.

@MichaelChirico MichaelChirico requested a review from AshesITR July 7, 2025 22:38
@AshesITR
Copy link
Collaborator

I wonder if there is a better way to allow requesting the old behavior.

Looking at the diff, the blast radius seems quite large.

@@ -38,6 +38,7 @@ linters: all_linters(
`<<-` = NULL
)),
unnecessary_concatenation_linter(allow_single_expression = FALSE),
cyclocomp_linter = if (requireNamespace("cyclocomp", quietly = TRUE)) cyclocomp_linter(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This we should avoid I think. It could inadvertently disable the linter for its core purpose (linting lintr) if the dev dependencies aren't correct elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True... any ideas? The problem is that both R-CMD-check-hard and R-CMD-check GHA use this same config, but the former can't work without cyclocomp_linter().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was a good idea to not parse settings by default for lint(text=).
If we want to go back on that, maybe add a step in R-CMD-check-hard that removes our .lintr file entirely before running?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so too, however, I don't know how else to restore the Emacs behavior described in the issue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the (7 year old) ess-lint code correctly, it gives all arguments to lint() by position.
We could soft-deprecate parsing settings if the code is pushed in via file= instead of text=.
WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the deprecation path, exactly? Would it suffice for tools like ess-lint to explicitly supply parse_settings=TRUE? Or such tools are required to do full-file parsing instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think explicitly requesting parse_settings = TRUE is a good way forward.

@bastistician
Copy link

Two comments from the outside:

  1. The use of parse_settings=FALSE in tests doesn't seem to be a bad idea, citing from vignette("lintr") (emphasis mine):

    If only the specified settings should be changed, and the remaining settings should be taken directly from the defaults, the argument parse_settings = FALSE can be added to the function calls. This will suppress reading of the .lintr configuration. This is particularly useful for tests which should not exclude example files containing lints while the package-level .lintr excludes those files because the lints are intentional.

  2. For the purpose of ess-r-flymake, it seems to be sufficient to keep respecting options("lintr.linter_file") when that gives an absolute path, even when linting "inline" code. Maybe this can simplify things and avoid the proposed read_settings() kludge filename <- "./any_local_file"?

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.

lintr::lint(text=) no longer reads personal settings
3 participants