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

Implicit Parentheses Around Method Arguments #727

Open
drernie opened this issue Jan 30, 2023 · 1 comment
Open

Implicit Parentheses Around Method Arguments #727

drernie opened this issue Jan 30, 2023 · 1 comment

Comments

@drernie
Copy link

drernie commented Jan 30, 2023

Groovy allows optional parentheses.
However, there seems only a single Rule for when they are NOT required:

https://codenarc.org/codenarc-rules-unnecessary.html#unnecessaryparenthesesformethodcallwithclosure-rule

If a method is called and the only parameter to that method is an inline closure then the parentheses of the method call can be omitted.

There's a case to be made for requiring ALL methods to have explicit parentheses, for consistency and unambiguity. Is that something you might be willing to support?

From: nvuillam/npm-groovy-lint#267

@chrismair
Copy link
Contributor

There's a case to be made for requiring ALL methods to have explicit parentheses, for consistency and unambiguity. Is that something you might be willing to support?

Probably not. There are certain idiomatic cases where parentheses would be unexpected and unpleasant, including where the last argument is a Closure, as that rule checks for.

There is also issue #433 , now a few years old, discussing a rule for checking for unnecessary parentheses, which I believe is the opposite of what you are asking about.

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

No branches or pull requests

2 participants