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

Bump PMD with fixes #25

Merged
merged 1 commit into from
Sep 26, 2024
Merged

Bump PMD with fixes #25

merged 1 commit into from
Sep 26, 2024

Conversation

brinxmat
Copy link
Contributor

  • Bumps PMD to a version that actually works with Java 21
  • Fixes the errors (some fixes may be ignorant/heavy handed, so do check
  • Removes checkstyle errors
  • Fixes a minor antipattern

</rule>

<rule ref="category/java/multithreading.xml">
<!-- Because it complains for the Map interface in the Resource class.-->
<!-- Because it complains about the Map interface in the Resource class.-->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We share Pub-API's PMD spec, but this isn't relevant for us…weird. Probably need to decide what to do about "Standard" and local colour in another meeting.

@@ -24,10 +23,10 @@ public class ApiData {

private final RestApi awsRestApi;
private final OpenAPI openapiApiGateway;
private Optional<OpenAPI> openapiApiGithub;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Optional fields are a no-no, I replaced this with a private getter…it serves little real purpose aside hiding null checks. I suspect we simply have a suboptimal design here (typically, we see this kind of thing when the OO is off), which should probably be rectified.

@@ -93,27 +95,29 @@ public ApiData setEmptySchemasIfNull() {
}

public ApiData overridePropsFromGithub() {
if (this.openapiApiGithub.isPresent()) {
var openApiGithub = getOpenapiApiGithub();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is here, it really adds nothing. Probably, there is a missing object.

@@ -118,8 +117,8 @@ private void removeTags(OpenAPI api) {

private void mergeSecurity(OpenAPI api) {
if (nonNull(api.getSecurity())) {
for (SecurityRequirement securityRequirement : api.getSecurity()) {
logger.info("adding security req {}", securityRequirement.toString());
for (var securityRequirement : api.getSecurity()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a cheap trick to avoid the prescription to use the interface, which here would have been quite harmful. It is not just us that makes things difficult on ourselves.

}

public ApiData setEmptySchemasIfNull() {
public ApiData applyEmptySchemasIfNull() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setters traditionally return void. I agree strongly with this pattern.

@sondrev sondrev merged commit 655e680 into main Sep 26, 2024
4 checks passed
@brinxmat brinxmat deleted the bump-pmd-2024-09-26 branch September 26, 2024 12:30
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.

4 participants