Skip to content

Best Practices PMD rules #14904

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

Merged
merged 10 commits into from
Jul 22, 2022
Merged

Best Practices PMD rules #14904

merged 10 commits into from
Jul 22, 2022

Conversation

alovew
Copy link
Contributor

@alovew alovew commented Jul 20, 2022

Implement the following Best Practices PMD rules:

LiteralsFirstInComparisons
LooseCoupling
PreserveStackTrace
SwitchStmtsShouldHaveDefault
SystemPrintln
UseCollectionIsEmpty
UseVarargs

@github-actions github-actions bot added area/platform issues related to the platform area/scheduler area/server area/worker Related to worker labels Jul 20, 2022
@alovew alovew temporarily deployed to more-secrets July 20, 2022 23:36 Inactive
@alovew alovew temporarily deployed to more-secrets July 21, 2022 19:08 Inactive
@alovew alovew force-pushed the anne/best-practices-pmd-3 branch from 608c6c1 to 6f0fdd3 Compare July 21, 2022 19:09
@alovew alovew temporarily deployed to more-secrets July 21, 2022 19:11 Inactive
if (metricClient != null) {
throw new RuntimeException("You cannot initialize configuration more than once.");
}

if (configs.getMetricClient().equals(DATADOG_METRIC_CLIENT)) {
if (DATADOG_METRIC_CLIENT.equals(configs.getMetricClient())) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually saw a bug in dev recently due to this, so this is good to fix.

LOGGER.warn("Failed to successfully notify auto-disable connection warning: {}", notification);
}

if (FAILURE_NOTIFICATION == action) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking at this again, thinking maybe I should use a default and log something like "unknown action"?

case STDERR -> LOGGER.error(message);
// assumption that this is an empty frame that connotes the container exiting.
case END -> LOGGER.error(service + " stopped!!!");
// default includes STDOUT and anything else
default -> LOGGER.info(message);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

opinions on setting this as the default?

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems fine. Worst case scenario is that we get a few extra cases logged to INFO.

case DEBUG -> logger.debug(logMessage.getMessage());
case TRACE -> logger.trace(logMessage.getMessage());
default -> logger.info(logMessage.getMessage());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

opinions on this default? (similar to above)

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fine.

@alovew alovew temporarily deployed to more-secrets July 21, 2022 19:28 Inactive
@alovew alovew temporarily deployed to more-secrets July 21, 2022 19:57 Inactive
@alovew alovew temporarily deployed to more-secrets July 21, 2022 20:09 Inactive
@alovew alovew temporarily deployed to more-secrets July 21, 2022 20:36 Inactive
Copy link
Contributor

@jdpgrailsdev jdpgrailsdev left a comment

Choose a reason for hiding this comment

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

:shipit:

@alovew alovew merged commit 555efd5 into master Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform area/scheduler area/server area/worker Related to worker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants