Randgalt / record-builder

Record builder generator for Java records
Apache License 2.0
758 stars 55 forks source link

Method names should start with a lower case letter #100

Closed faris-git closed 2 years ago

faris-git commented 2 years ago

As my SAST vulnerability report tool always complain that "Method names should start with a lower case letter". Is there any reason to use static constructor method name with capital letter.

@RecordBuilder
public record MyRecord(String name){}

The generated code:

     /**
     * Static constructor/builder. Can be used instead of new MyRecord(...)
     */
    @Generated("io.soabase.recordbuilder.core.RecordBuilder")
    public static MyRecord MyRecord(String name) {...}

Identifier: Find Security Bugs-NM_METHOD_NAMING_CONVENTION

May be it would be great if we can configure the method name conventions.

Expected generated code:

 /**
     * Static constructor/builder. Can be used instead of new MyRecord(...)
     */
    @Generated("io.soabase.recordbuilder.core.RecordBuilder")
    public static MyRecord myRecord(String name) {...}
Randgalt commented 2 years ago

This is a common pattern in FP. You can see an example of it here: https://github.com/Randgalt/expressive-java - we could add an option, though, to not generate the method.

faris-git commented 2 years ago

Thanks @Randgalt