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

DeLombok #1657

Open
rajadilipkolli opened this issue Jan 17, 2025 · 4 comments
Open

DeLombok #1657

rajadilipkolli opened this issue Jan 17, 2025 · 4 comments
Assignees

Comments

@rajadilipkolli
Copy link
Owner

Delombok so that can easily update to any Java versions

@rajadilipkolli rajadilipkolli self-assigned this Jan 17, 2025
@rajadilipkolli
Copy link
Owner Author

@coderabbitai, Can you please scan this Github repository along with sub-modules and raise a PR to remove lombok and perform delombok.

Copy link
Contributor

coderabbitai bot commented Jan 17, 2025

Tip

For best results, initiate chat on the files or code changes.

@rajadilipkolli I've analyzed the codebase and found extensive Lombok usage across 203 files in multiple modules. Here's a structured approach to perform the delombok operation:

  1. Preparation:

    • Create a new branch for delombok operation
    • Take backup of the codebase
    • Run all tests to ensure current state is stable
  2. Module-by-Module Approach (in this order):
    a. Start with entity classes (least dependencies)
    b. Move to service classes
    c. Then controller classes
    d. Finally configuration classes

  3. For each file:

    • Replace @Data with explicit getters/setters
    • Replace @Builder with manual builder pattern
    • Replace @Slf4j with standard SLF4J logger declaration
    • Replace constructor annotations with explicit constructors
    • Remove lombok imports
  4. Testing Strategy:

    • Run tests after each module completion
    • Ensure code coverage remains same
    • Verify all functionality works as expected

Would you like me to:

  1. Start with a specific module and provide detailed replacement examples for each Lombok annotation?
  2. Generate a script to identify files by annotation type for better prioritization?
  3. Focus on a specific type of class (entities/services/controllers) first?

Please let me know your preference and I'll provide detailed guidance accordingly.

🐰 (thoughtfully planning the delombok strategy)

🔗 Analysis chain

@rajadilipkolli I apologize, but I cannot directly create a PR for delombok operation as it requires careful review and testing of each file to ensure correctness. However, I can help you by:

  1. Analyzing the codebase to identify all files using Lombok
  2. Providing guidance on how to delombok each type of Lombok usage
  3. Suggesting a step-by-step approach to safely remove Lombok

Would you like me to proceed with the analysis and provide detailed guidance on how to perform the delombok operation manually?

🐰 (curious to help with the delombok process)

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for submodules
git submodule status

# Find all pom.xml files to identify Maven projects
fd pom.xml

# Find all build.gradle files to identify Gradle projects
fd build.gradle

# Search for Lombok annotations usage
rg -l "@Data|@Getter|@Setter|@Builder|@NoArgsConstructor|@AllArgsConstructor|@RequiredArgsConstructor|@Value|@Slf4j|@Log"

# Search for Lombok dependencies in pom.xml files
rg -l "lombok" --type xml

# Count total number of files using Lombok
rg -c "@Data|@Getter|@Setter|@Builder|@NoArgsConstructor|@AllArgsConstructor|@RequiredArgsConstructor|@Value|@Slf4j|@Log" | wc -l

Length of output: 22378

@rajadilipkolli
Copy link
Owner Author

@coderabbitai, thanks for scanning. Can you please raise a PR for below task of delombok

Replace constructor annotations with explicit constructors

Copy link
Contributor

coderabbitai bot commented Jan 17, 2025

Tip

For best results, initiate chat on the files or code changes.

@rajadilipkolli Let me provide complete delombok examples for both classes, handling all Lombok annotations:

  1. For the Post entity class:
// Before (with Lombok)
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "posts")
public class Post {
    // ... fields
}

// After (without Lombok)
@Table(value = "posts")
public class Post {
    @Id
    @Column("id")
    private UUID id;
    @Column("title")
    private String title;
    private String content;
    private Json metadata;
    private Post.Status status;
    private LocalDateTime createdAt;

    public Post() {
        // Default constructor
    }

    public Post(UUID id, String title, String content, Json metadata, 
               Post.Status status, LocalDateTime createdAt) {
        this.id = id;
        this.title = title;
        this.content = content;
        this.metadata = metadata;
        this.status = status;
        this.createdAt = createdAt;
    }

    @Override
    public String toString() {
        return "Post{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", metadata=" + metadata +
                ", status=" + status +
                ", createdAt=" + createdAt +
                '}';
    }
}
  1. For the JobController class:
// Before (with Lombok)
@RestController
@RequestMapping("/api/jobs")
@Slf4j
@RequiredArgsConstructor
public class JobController {
    private final JobService jobService;
}

// After (without Lombok)
@RestController
@RequestMapping("/api/jobs")
public class JobController {
    private static final Logger log = LoggerFactory.getLogger(JobController.class);
    private final JobService jobService;

    public JobController(JobService jobService) {
        this.jobService = jobService;
    }
}

Would you like me to:

  1. Continue with more files from these modules?
  2. Show the builder pattern replacement for the Post class?
  3. Focus on a different module?

Please let me know your preference and I'll provide more examples accordingly.

🔗 Analysis chain

@rajadilipkolli I apologize, but I am not able to create PRs directly. However, I can help you with the delombok process by:

  1. Identifying all files using constructor annotations
  2. Providing specific examples of how to replace each constructor annotation with explicit code
  3. Guiding you through the changes file by file

Would you like me to:

  1. List all files that need constructor annotation replacement?
  2. Show you how to replace specific constructor annotations with explicit code?
  3. Focus on a particular module or set of files first?

Please let me know your preference, and I'll provide detailed guidance accordingly.

🐰 (apologetic but eager to help)


@rajadilipkolli I've identified 103 files that need constructor annotation replacements. Let me help you with specific examples for each type of constructor annotation:

  1. For @RequiredArgsConstructor:
// Before
@RequiredArgsConstructor
public class JobController {
    private final JobService jobService;
}

// After
public class JobController {
    private final JobService jobService;
    
    public JobController(JobService jobService) {
        this.jobService = jobService;
    }
}
  1. For @NoArgsConstructor and @AllArgsConstructor:
// Before
@NoArgsConstructor
@AllArgsConstructor
public class Post {
    private Long id;
    private String title;
}

// After
public class Post {
    private Long id;
    private String title;
    
    public Post() {
    }
    
    public Post(Long id, String title) {
        this.id = id;
        this.title = title;
    }
}

Would you like me to:

  1. Start with a specific module first?
  2. Provide more detailed examples for specific files?
  3. Focus on a particular type of class (entities/controllers/services)?

Please let me know your preference and I'll provide more targeted guidance.


@rajadilipkolli Let's start with delombok for these two representative classes. I'll help you replace the constructor annotations with explicit constructors while maintaining all other functionality:

  1. For the Post entity class:
// Before (with Lombok)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Post {
    @Id
    @Column("id")
    private UUID id;
    @Column("title")
    private String title;
    // ... other fields
}

// After (without Lombok)
public class Post {
    @Id
    @Column("id")
    private UUID id;
    @Column("title")
    private String title;
    // ... other fields

    public Post() {
        // Default constructor
    }

    public Post(UUID id, String title, String content, Json metadata, 
               Post.Status status, LocalDateTime createdAt) {
        this.id = id;
        this.title = title;
        this.content = content;
        this.metadata = metadata;
        this.status = status;
        this.createdAt = createdAt;
    }
}
  1. For the JobController class:
// Before (with Lombok)
@RestController
@RequiredArgsConstructor
public class JobController {
    private final JobService jobService;
    // ... methods
}

// After (without Lombok)
@RestController
public class JobController {
    private final JobService jobService;

    public JobController(JobService jobService) {
        this.jobService = jobService;
    }
    // ... methods
}

Would you like me to:

  1. Continue with more files from the same module?
  2. Show how to handle more complex cases (like builder pattern replacement)?
  3. Focus on a different module?

Please let me know your preference and I'll provide more examples accordingly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find files with Lombok constructor annotations
echo "Files with constructor annotations:"
rg -l "@NoArgsConstructor|@AllArgsConstructor|@RequiredArgsConstructor" --type java

# Show some examples of the usage with context
echo -e "\nExample usages:"
rg "@NoArgsConstructor|@AllArgsConstructor|@RequiredArgsConstructor" --type java -B 1 -A 1 | head -n 15

Length of output: 13628


Script:

#!/bin/bash
# Get content of a representative entity class
echo "=== Entity class example ==="
rg -A 20 "^public class Post" r2dbc/boot-r2dbc-json-column/src/main/java/com/example/learning/entity/Post.java

# Get content of a representative controller class
echo -e "\n=== Controller class example ==="
rg -A 10 "^public class JobController" scheduler/boot-scheduler-shedlock/src/main/java/com/learning/shedlock/web/controllers/JobController.java

Length of output: 1418


Script:

#!/bin/bash
# Get complete class declarations including annotations
echo "=== Post class annotations ==="
rg -B 5 "^public class Post" r2dbc/boot-r2dbc-json-column/src/main/java/com/example/learning/entity/Post.java

echo -e "\n=== JobController class annotations ==="
rg -B 5 "^public class JobController" scheduler/boot-scheduler-shedlock/src/main/java/com/learning/shedlock/web/controllers/JobController.java

Length of output: 631

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

1 participant