-
Notifications
You must be signed in to change notification settings - Fork 47
fix(GCI82): fix rule to handle Lombok generated setters #113
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| import java.util.logging.Logger; | ||
| import lombok.Setter; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the first use case ... using real imports like that. |
||
| import lombok.Data; | ||
| import lombok.AccessLevel; | ||
|
|
||
| public class MakeNonReassignedVariablesConstants { | ||
|
|
||
| private final Logger logger = Logger.getLogger(""); // Compliant | ||
|
|
||
| @Setter | ||
| private String myLombokManagedString = "initialValue"; // Compliant | ||
|
|
||
| private Object myNonFinalAndNotReassignedObject = new Object(); // Noncompliant {{The variable is never reassigned and can be 'final'}} | ||
| private Object myNonFinalAndReassignedObject = new Object(); // Compliant | ||
| private final Object myFinalAndNotReassignedObject = new Object(); // Compliant | ||
|
|
@@ -66,4 +72,22 @@ void classVariableReassignedBis() { | |
| logger.info(myFinalAndNotReassignedObject.toString()); | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
||
| @Setter | ||
| class myExtraClassWithLombokSetter { | ||
| private String myExtraClassString = "initialValue"; // Compliant | ||
| private final String myExtraClassFinalString = "initialValue"; // Compliant | ||
|
|
||
| @Setter(AccessLevel.NONE) // Noncompliant {{The variable is never reassigned and can be 'final'}} | ||
| private String myExtraClassSetterNoneString = "initialValue"; | ||
| } | ||
|
|
||
| @Data | ||
| class myExtraClassWithLombokData { | ||
| private String myExtraClassString = "initialValue"; // Compliant | ||
| private final String myExtraClassFinalString = "initialValue"; // Compliant | ||
|
|
||
| @Setter(AccessLevel.NONE) // Noncompliant {{The variable is never reassigned and can be 'final'}} | ||
| private String myExtraClassSetterNoneString = "initialValue"; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can improve more efficiently the import checks. You can add "Kind.IMPORT" in the list of nodes to check. Because Imports are the first statements analyezed in the code, you can know if lombok importrs are present or not.