GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactored data clumps with the help of LLMs (research project) by compf · Pull Request #3867 · junit-team/junit-framework

Conversation

@compf

@compf compf commented Jun 21, 2024

Copy link
Copy Markdown
Contributor

Overview

Hello maintainers,

I am conducting a master thesis project focused on enhancing code quality through automated refactoring of data clumps, assisted by Large Language Models (LLMs).

Data clump definition

A data clump exists if

  1. two methods (in the same or in different classes) have at least 3 common parameters and one of those methods does not override the other, or
  2. At least three fields in a class are common with the parameters of a method (in the same or in a different class), or
  3. Two different classes have at least three common fields

See also the following UML diagram as an example
Example data clump

I believe these refactoring can contribute to the project by reducing complexity and enhancing readability of your source code.

Pursuant to the EU AI Act, I fully disclose the use of LLMs in generating these refactorings, emphasizing that all changes have undergone human review for quality assurance.

Even if you decide not to integrate my changes to your codebase (which is perfectly fine), I ask you to fill out a feedback survey, which will be scientifically evaluated to determine the acceptance of AI-supported refactorings. You can find the feedback survey under https://campus.lamapoll.de/Data-clump-refactoring/en

Thank you for considering my contribution. I look forward to your feedback. If you have any other questions or comments, feel free to write a comment, or email me under [email protected] .

Best regards,
Timo Schoemaker
Department of Computer Science
University of Osnabrück

I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

  • There are no TODOs left in the code
  • Method preconditions are checked and documented in the method's Javadoc
  • Coding conventions (e.g. for logging) have been followed
  • Change is covered by automated tests including corner cases, errors, and exception handling
  • Public API has Javadoc and @API annotations
  • Change is documented in the User Guide and Release Notes

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@compf
refactored data clumps
863a4d2
mpkorstanje
mpkorstanje reviewed Jun 27, 2024
View reviewed changes

@mpkorstanje mpkorstanje left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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'm not part of the JUnit Team. But I thought this PR looked interesting. And I left some suggestions, hope you find them useful.

Overall I think this refactoring has the right idea. Extracting the counter was the right action and does improve things. But this refactoring also unlocked some benefits that are not yet utilized.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/HandlerCallCounter.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...t/java/org/junit/jupiter/engine/extension/LifecycleMethodExecutionExceptionHandlerTests.java Outdated

assertEquals(1, RethrowExceptionHandler.beforeAllCalls, "Exception should handled in @BeforeAll");
assertEquals(1, RethrowExceptionHandler.afterAllCalls, "Exception should handled in @AfterAll");
assertEquals(1, RethrowExceptionHandler.callCounter.getBeforeAllCalls(),

@mpkorstanje mpkorstanje Jun 27, 2024

Copy link
Copy Markdown
Member

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.

With the introduction of the HandlerCallCounter there is no need to store the counts as a field in the handler. You could now declare a HandlerCallCounter rethrowCounter as a static field on LifecycleMethodExecutionExceptionHandlerTests and reference that everywhere. I.e.

assertEquals(1, rethrowCounter.getBeforeAllCalls(), "Exception should handled in @BeforeAll");

With some thoughtfully chosen method and field names this would reduce the verbosity of the code a bit and keep the whole assertion on a single line.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
marcphilipp
marcphilipp requested changes Jun 28, 2024
View reviewed changes
Comment thread junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/HandlerCallCounter.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/HandlerCallCounter.java Outdated
Comment on lines +30 to +60
public void incrementBeforeAllCalls() {
beforeAllCalls++;
}

public void incrementBeforeEachCalls() {
beforeEachCalls++;
}

public void incrementAfterEachCalls() {
afterEachCalls++;
}

public void incrementAfterAllCalls() {
afterAllCalls++;
}

public int getBeforeAllCalls() {
return beforeAllCalls;
}

public int getBeforeEachCalls() {
return beforeEachCalls;
}

public int getAfterEachCalls() {
return afterEachCalls;
}

public int getAfterAllCalls() {
return afterAllCalls;
}

@marcphilipp marcphilipp Jun 21, 2024

Copy link
Copy Markdown
Member

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.

Since this class is only a local test helper, I don't think we need to encapsulate the fields. Therefore, I think these methods should be inlined.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@compf

compf commented Jul 1, 2024

Copy link
Copy Markdown
Contributor Author

Thank you very much for the feedback. @marcphilipp I have just applied the suggested changes.

@mpkorstanje While I like your reasoning, I think this should be part of a larger redesign of the test classes. I haven't implement your proposal for now but I would be happy to do so if others concur

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@compf
moved HandlerCallsCounter to inner class and removed getter
3f75c2f
@compf
compf force-pushed the refactor_data_clumps branch from eb0cf99 to 3f75c2f Compare July 1, 2024 18:19
marcphilipp
marcphilipp approved these changes Jul 2, 2024
View reviewed changes
@marcphilipp marcphilipp added this to the 5.11 M3 milestone Jul 2, 2024
@marcphilipp
marcphilipp merged commit 50b2856 into junit-team:main Jul 2, 2024
@marcphilipp

marcphilipp commented Jul 2, 2024

Copy link
Copy Markdown
Member

@compf Thanks! 👍

compf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vlsi vlsi mentioned this pull request Oct 13, 2026
Contribution guidelines do not say whether AI-assisted pull requests and issues are acceptable #6155
Closed
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mpkorstanje mpkorstanje mpkorstanje left review comments
@marcphilipp marcphilipp marcphilipp approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

5.11 RC1

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@compf @marcphilipp @mpkorstanje
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.