Skip to content
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

Support Box #1087

Closed
latot opened this issue Apr 20, 2022 · 8 comments · Fixed by #1105
Closed

Support Box #1087

latot opened this issue Apr 20, 2022 · 8 comments · Fixed by #1105
Labels
help wanted ❤️ we'd love your help!

Comments

@latot
Copy link

latot commented Apr 20, 2022

Hi, I'm using lintr in code and github, I think would be great support the box module, because actually lintr don't detect the functions contained in the modules.

https://github.com/klmr/box

Thx.

@MichaelChirico MichaelChirico added the help wanted ❤️ we'd love your help! label Apr 20, 2022
@AshesITR
Copy link
Collaborator

Hi, can you describe what kind of support you'd like?
Note that the object_usage_linter can see functions defined in your globalenv, so it may help to import your boxes before calling lint() if you see too many false positives from that particular linter.

@latot
Copy link
Author

latot commented Apr 22, 2022

mm, I have a code, but seems the problem is in other place, i'll check it deeper, for now, I think would be great a fix for this:

b.R:1:11: style: Put spaces around all infix operators.
box::use(./a)

Thx.

@MichaelChirico
Copy link
Collaborator

seems like an unfortunate syntax choice by box to save 2 characters IMO

@AshesITR
Copy link
Collaborator

If you are using the development version of lintr, you could wrap your box::use() statements in a nolint block like this:

# nolint start: infix_spaces_linter.
box::use(./a)
# nolint end

@latot
Copy link
Author

latot commented Apr 25, 2022

I'm not using the dev version, I was checking the options, I think woukd be great have a little more doc about how to use the options. For now, I put an issue in box, this can works as a workaround thx! still think this need a proper solution.

@AshesITR
Copy link
Collaborator

In lintr 2.0.1, you can use # nolint start instead of # nolint start: infix_spaces_linter. as a workaround (though this will suppress all lints in the surrounded region, so use with care).

@klmr
Copy link
Contributor

klmr commented Apr 25, 2022

seems like an unfortunate syntax choice by box to save 2 characters IMO

Just to be clear, the reason why ‘box’ uses unquoted expressions is not “to save 2 characters”. For the curious, klmr/box#68 has an explanation of the rationale (tl;dr: type correctness).

— Do ‘lintr’ rules support scoping? I.e. could I write a ‘lintr’ rule that would enforce space around binary operators except inside a box::use declaration?

@AshesITR
Copy link
Collaborator

Yes, @klmr, the infix_spaces_linter uses the XML parse tree, so can do arbitrary XPath based rules to lint or not lint something.
To avoid false negatives, it's probably best to exactly match box::use(<expr>/<expr>) as a negative in this case.

Feel free to create a PR adding this exception to infix_spaces_linter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted ❤️ we'd love your help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants