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

WW-5279 Improve readability of XmlConfigurationProvider class #657

Merged

Conversation

kusalk
Copy link
Member

@kusalk kusalk commented Jan 30, 2023

Copy link
Contributor

@sepe81 sepe81 left a comment

Choose a reason for hiding this comment

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

not easy to overlook the big diff, but good to see the cognitive complexity reduced afterwards


final XmlConfigurationProvider xmlConfigurationProvider = (XmlConfigurationProvider) o;

XmlConfigurationProvider xmlConfigurationProvider = (XmlConfigurationProvider) o;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
XmlConfigurationProvider xmlConfigurationProvider = (XmlConfigurationProvider) o;
final XmlConfigurationProvider xmlConfigurationProvider = (XmlConfigurationProvider) o;

this could remain final

Copy link
Member Author

Choose a reason for hiding this comment

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

I find it clutters the code and goes against present common practice - but I can revert these changes if that is the preferred code style.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://stackoverflow.com/questions/154314/when-should-one-use-final-for-method-parameters-and-local-variables/154510#154510 LGTM, but for this existing line "If I'm in someone else's code, I'm not going to pull them out but if I'm writing new code I won't put them in." would fit.

With your explanation, both styles would be ok for me. Maybe @lukaszlenart has some recommendation according to the Struts coding style?

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with dropping final in this context, I like using finals for fields and function arguments, where it makes sense :)

LOG.error("Unable to verify action [{}] with class [{}], from [{}]", name, className, location);
return;
}
if (!className.isEmpty() && !verifyAction(className, name, location)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can remove the unused param name from verifyAction L:490

Sonar says: Parameter 'name' is never used

Copy link
Member Author

Choose a reason for hiding this comment

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

There's multiple methods in this class with unused params - I've kept them to maintain compatibility with potential subclasses. Perhaps something to revisit when releasing the next major version.

Copy link
Member

Choose a reason for hiding this comment

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

@sepe81 I'm right now creating a task to mark a given code @Deprecated and then another task (targeting major/minor release) to remove the code. I found such approach more useful and more informative for the users :)

Copy link
Member

@lukaszlenart lukaszlenart left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@lukaszlenart lukaszlenart merged commit 930c6de into apache:master Feb 1, 2023
@kusalk kusalk deleted the WW-5279-xml-config-provider branch March 1, 2023 07:44
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.

3 participants