[no-array-method-this-argument] Ignore usages with method references
See original GitHub issueThe no-array-method-this-argument
is useful and makes sense, however in some cases I believe it should not warn. For example:
value.map(x.someMethod, x);
Imagine that someMethod
uses this
so it should be correct when invoking it.
The rule complains about this usage but 1) removing the thisArg
is wrong and 2) changing the code to value.map(v => x.someMethod(v))
is uglier (and is not as “functional-style” as the other).
So I propose in this case the rule to not warn for such code - where a method reference is used as the first argument to map
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Find Usages. Method Options | IntelliJ IDEA Documentation
This section describes the controls for specifying Method Usage Search ... search is performed for all references of the method by its name....
Read more >Method References (The Java™ Tutorials > Learning the Java ...
Method References. You use lambda expressions to create anonymous methods. Sometimes, however, a lambda expression does nothing but call an existing method.
Read more >Intellij - can be replaced with method reference - Stack Overflow
I get the following statement: "Non-static method cannot be referenced from a static context". Why Idea suggests me I should use method ......
Read more >Java 8 Method Reference: How to Use it | Codementor
In Java, we can use references to objects, either by creating new ... So to use a method reference, you first need a...
Read more >Method References in Java with examples - GeeksforGeeks
A code is more clear and short if one uses a lambda expression rather than using an anonymous class and one can use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not neutral on adding such option, but if added, it should be
false
by default.@sindresorhus - you’re right that it’s subjective. That’s why I prefer the other one. I’m also not sure about the performance - I could only guess that creating a bound function is slower than passing
this
explicitly.Anyway, that’s my opinion and preference. An option to skip such cases where the first argument is a method reference (perhaps also a function name but I could argue that in that case a
bind
is better) would be nice. 😃