Yeah, it is the real deal if you are looking for a linter tool like
this. Fast like ruff linter for python, but for more languages and you
can write the rules.

Give your rule an id: too-many-arguments and maybe a url:
https://mail.openjdk.... and then you've got nice diagnostics in the
editor too. false-positives can be disabled with a comment of
'ast-grep-ignore: too-many-arguments'. You can add a "fix" and it will
be available as code action in the editor as well. And it has a test
facility so you can have valid/invalid cases to keep it working and
fine-tune it.

On Fri, Jan 31, 2025 at 9:00 AM Dawid Weiss <dawid.we...@gmail.com> wrote:
>
>
> That's a very interesting project, thanks for sharing!
>
> Dawid
>
> On Thu, Jan 30, 2025 at 11:25 PM Robert Muir <rcm...@gmail.com> wrote:
>>
>> For this one I would use ast-grep, maybe set threshold at 100
>> arguments which is a crazy amount and would detect where things might
>> go bad. You might have to refine this example, but it is good for such
>> things and fast as hell.
>>
>> https://s.apache.org/ueozj
>>
>> On Thu, Jan 30, 2025 at 5:27 PM Chris Hostetter
>> <hossman_luc...@fucit.org> wrote:
>> >
>> >
>> > : Have seen it on other cases, too. Seems to happen when you create long 
>> > lists
>> > : based on methods that use generics for their return type.
>> >
>> > Havng gone down Dawid's compiler-dev@ thread rabbit hole: correct.
>> >
>> > : The workaround is to hardcode the type in the asList() call, then the 
>> > code
>> > : does not have to handle the generic return of each parameter:
>> > :
>> > :       Arrays.<Entry<String,String>>asList(....)
>> >
>> > Uwe: does forbidden-apis have enough type information to recognize:
>> >   1) the length of a varargs list
>> >   2) when the source code it's checking is missing explicit generic type
>> > declarations in the method call
>> >
>> >
>> > I'm wondering if a new forbidden-api feature could restrict usage based on
>> > generics and/or varargs length, such that we could write a rule saying
>> > "Arrays.asList w/ varargs.length > 3 must specify explicit type"
>> >
>> > So this would be forbidden...
>> >
>> >    Arrays.asList("x", 2, "y", 3);
>> >
>> > ...but these would be legal...
>> >
>> >     Arrays.<Object>asList("x", 2, "y", 3);
>> >     Arrays.asList("x", 2, foo);
>> >
>> >
>> >
>> >
>> > -Hoss
>> > http://www.lucidworks.com/
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
>> > For additional commands, e-mail: dev-h...@lucene.apache.org
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: dev-h...@lucene.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to