-
Notifications
You must be signed in to change notification settings - Fork 834
WW-5352 Refactor ParametersInterceptor #831
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
Conversation
9afea18 to
5c7a6bc
Compare
5c7a6bc to
8a245e8
Compare
| * @param value to check | ||
| * @return object containing result of matched pattern and pattern itself | ||
| */ | ||
| public IsAccepted isAccepted(String value); |
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.
Redundant in interfaces
| @Override | ||
| public String getValue() { | ||
| String[] values = toStringArray(); | ||
| return (values != null && values.length > 0) ? values[0] : null; |
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.
#toStringArray never returns a null value
| }; | ||
|
|
||
| @Override | ||
| public String doIntercept(ActionInvocation invocation) throws Exception { |
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.
Used early returns to reduce nesting and improve readability
| protected void addParametersToContext(ActionContext ac, Map<String, ?> newParams) { | ||
| } | ||
|
|
||
| protected void setParameters(final Object action, ValueStack stack, HttpParameters parameters) { |
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.
Extracted a bunch of helper methods to make this method much more readable
| boolean acceptableParamValue = (parameterValueAware == null || parameterValueAware.acceptableParameterValue(param.getValue())); | ||
| if (hasParamValuesToExclude() || hasParamValuesToAccept()) { | ||
| // Additional validations to process | ||
| acceptableParamValue &= acceptableValue(param.getName(), param.getValue()); |
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.
&= doesn't short-circuit
| return false; | ||
| } | ||
| boolean accepted = isWithinLengthLimit(name) && !isExcluded(name) && isAccepted(name); | ||
| if (devMode && accepted) { // notify only when in devMode |
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.
Cleaned out comments for behaviours which are fairly obvious from code
core/src/main/java/org/apache/struts2/interceptor/parameter/ParametersInterceptor.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/struts2/interceptor/parameter/ParametersInterceptor.java
Outdated
Show resolved
Hide resolved
|
|
@lukaszlenart Any idea how to configure a second base branch for SonarCloud dedicated to 7.x so we don't get wonky results? |



WW-5352
General clean up in preparation for #832