Skip to content

Conversation

@asya-vorobeva
Copy link
Contributor

@asya-vorobeva asya-vorobeva commented Jan 26, 2026

Added CheckVerifier.withDependenciesToChange() method to configure needed dependencies to add / remove from a classpath. See SONARJAVA-5973

@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Jan 26, 2026

SONARJAVA-5973

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a very nice improvement to have! I would change the method name and also add some specific tests for the JavaCheckVerifier

* @param jarsToRemove a collection of jar names (without extensions) to remove from the classpath
* @return the verifier configured to use the dependencies provided as arguments to change the classpath
*/
CheckVerifier withDependenciesToChange(List<String> jarsToAdd, List<String> jarsToRemove);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd rather have two separate methods, one to remove some jars, and the other to add them, this way we don't have the overhead of the order of parameters, and can also avoid handling null cases.
We could have something like

 CheckVerifier removeJarsFromClasspath(String... jarsToRemove);
 CheckVerifier addJarsToClasspath(String... jarsToAdd);


@Override
public CheckVerifier withDependenciesToChange(List<String> jarsToAdd, List<String> jarsToRemove) {
this.jarsToAdd = jarsToAdd;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to override we should be clear about it, from the javadoc and the signature I might think that everytime I call this method I am defining more libraries to add/remove on top of previous calls to the method.
I think if we switch to removeJarsFromClasspath and addJarsToClasspath, the implementation should also change to be "cumulative", so multiple calls would produce the expected result

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yep, I've completely forgot about verifier's tests... You're right, will do!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks a lot for the nice work!!

@asya-vorobeva asya-vorobeva force-pushed the asya/sonarjava-5973 branch 2 times, most recently from b2db71b to a112404 Compare January 28, 2026 13:24
@asya-vorobeva asya-vorobeva enabled auto-merge (rebase) January 28, 2026 13:25
@asya-vorobeva asya-vorobeva enabled auto-merge (squash) January 28, 2026 13:26
@sonarqube-next
Copy link

@asya-vorobeva asya-vorobeva merged commit 105f9ed into master Jan 28, 2026
16 checks passed
@asya-vorobeva asya-vorobeva deleted the asya/sonarjava-5973 branch January 28, 2026 13:59
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

Successfully merging this pull request may close these issues.

2 participants