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

undesirable_function_linter() could support a custom regex? #2701

Open
MichaelChirico opened this issue Dec 21, 2024 · 0 comments
Open

undesirable_function_linter() could support a custom regex? #2701

MichaelChirico opened this issue Dec 21, 2024 · 0 comments
Labels
feature a feature request or enhancement

Comments

@MichaelChirico
Copy link
Collaborator

I am looking at the default undesirable_function_linter() throwing for this:

par('usr')

because the default looks for any call to par(). But actually, what the lint reasoning really cares about is writing device settings, not reading them.

So we might want to tweak the XPath for par(): //SYMBOL_FUNCTION_CALL[text() = 'par']/parent::expr/following-sibling::EQ_SUB, i.e. it has to use a keyword argument.

I think this feature is quite generalizable -- I've definitely encountered situations where a function is undesirable in some-but-not-all circumstances, and rather than introducing a new par_linter() (or generally foo_linter()) every time there's a minor rule that's just outside of what undesirable_function_linter() can accomplish, it would be good to extend undesirable_function_linter() itself to be able to handle these situtations.

What remains is to come up with a good design for this. The first thing that comes to mind is to accept a list instead of just a string:

undesirable_function_linter(c(par = '...'))

undesirable_function_linter(list(par = list(lint_message = '...', xpath = '...')))

I think this would also help with (if not obviate) #1912, #1770.

@MichaelChirico MichaelChirico added the feature a feature request or enhancement label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant