Skip to content

Commit

Permalink
More checkstyle rules and style cleanup (MID-4715)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 21, 2019
1 parent d1c1457 commit e410d69
Show file tree
Hide file tree
Showing 201 changed files with 980 additions and 1,428 deletions.
Expand Up @@ -6,9 +6,13 @@
<suppress files="[/\\]generated[/\\]" checks=".*"/>
<suppress files="[/\\]generated-sources[/\\]" checks=".*"/>
<suppress files="[/\\]annotation_3[/\\]" checks="ConstantName"/>
<suppress files="[/\\]query_3[/\\]" checks="ConstantName"/>
<suppress files="[/\\]types_3[/\\]" checks="ConstantName"/>
<suppress files="[/\\]query_3[/\\]" checks="ConstantName|AvoidNestedBlocks|NeedBraces"/>
<suppress files="[/\\]types_3[/\\]" checks="ConstantName|AvoidNestedBlocks|NeedBraces"/>
<suppress files="[/\\]com[/\\]evolveum[/\\]midpoint[/\\]prism[/\\]delta[/\\]builder[/\\]" checks="TypeName"/>
<suppress files="[/\\]com[/\\]evolveum[/\\]midpoint[/\\]prism[/\\]query[/\\]builder[/\\]" checks="TypeName"/>
<suppress files="[/\\]com[/\\]evolveum[/\\]midpoint[/\\]prism[/\\]impl[/\\]query[/\\]builder[/\\]" checks="TypeName"/>

<!-- This will be gone anyway. Sooner or later. -->
<suppress files="[/\\]com[/\\]evolveum[/\\]midpoint[/\\]model[/\\]api[/\\]ModelPort.java$" checks="InterfaceIsType"/>
<suppress files="[/\\]com[/\\]evolveum[/\\]midpoint[/\\]report[/\\]api[/\\]ReportPort.java$" checks="InterfaceIsType"/>
</suppressions>
24 changes: 16 additions & 8 deletions build-tools/src/main/resources/midpoint-build/checkstyle.xml
Expand Up @@ -3,6 +3,7 @@
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!-- Based on checkstyle/src/main/resources/sun_checks.xml -->
<!-- See https://checkstyle.sourceforge.io/checks.html for explanation -->
<module name="Checker">
<!--
<property name="basedir" value="${basedir}"/>
Expand Down Expand Up @@ -40,21 +41,28 @@
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="RedundantImport"/>

<!-- TODO: enable this later
<module name="RedundantModifier"/>
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="NeedBraces"/>
<module name="EmptyBlock">
<property name="option" value="text"/>
</module>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="MultipleVariableDeclarations"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="FinalClass"/>
<module name="InterfaceIsType"/>
<module name="ArrayTypeStyle"/>
<module name="UpperEll"/> -->
<module name="UpperEll"/>

<!-- TODO: enable later (problem: eclipse equals() code)
<module name="NeedBraces">
<property name="allowSingleLineStatement" value="true"/>
</module>
-->

<!-- TODO: enable later (problem: too many of those)
<module name="FinalClass"/>
<module name="RedundantModifier"/>
-->


<!-- TODO: enable those MUCH later
Expand Down
Expand Up @@ -2457,11 +2457,7 @@ public static boolean getElementVisibility(UserInterfaceElementVisibilityType vi
return true;
}
if (UserInterfaceElementVisibilityType.AUTOMATIC.equals(visibilityType)){
if (WebComponentUtil.isAuthorized(requiredAuthorizations)){
return true;
} else {
return false;
}
return WebComponentUtil.isAuthorized(requiredAuthorizations);
}
return true;
}
Expand Down
Expand Up @@ -4,7 +4,6 @@
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.component.form;

import com.evolveum.midpoint.gui.api.component.BasePanel;
Expand All @@ -27,7 +26,6 @@
* @author skublik
*/
public class TriStateFormGroup extends BasePanel<Boolean> {

private static final long serialVersionUID = 1L;

private static final String ID_VALUE = "value";
Expand Down Expand Up @@ -119,15 +117,15 @@ public boolean isVisible() {
rowLabel.add(valueWrapper);
add(propertyLabel);

TriStateComboPanel triStateCombo = new TriStateComboPanel(ID_VALUE, getModel());;
TriStateComboPanel triStateCombo = new TriStateComboPanel(ID_VALUE, getModel());
valueWrapper.add(triStateCombo);

FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(triStateCombo.getBaseFormComponent()));
feedback.setOutputMarkupId(true);
valueWrapper.add(feedback);
}

public TriStateComboPanel getValue(){
public TriStateComboPanel getValue() {
return (TriStateComboPanel) get(createComponentPath(ID_PROPERTY_LABEL, ID_ROW, ID_VALUE_WRAPPER, ID_VALUE));
}
}
Expand Up @@ -240,7 +240,7 @@ protected void onComponentTag(final ComponentTag tag) {
protected void onBeforeRender() {
int index = getSelectedTab();

if (index == -1 || getVisiblityCache().isVisible(index) == false) {
if (index == -1 || !getVisiblityCache().isVisible(index)) {
// find first visible tab
index = -1;
for (int i = 0; i < tabs.getObject().size(); i++) {
Expand Down
Expand Up @@ -561,7 +561,6 @@ public PrismContainerValue<AssignmentType> getNewValue(PrismContext prismContext
if (orgRef != null && AssignmentEditorDtoType.ROLE.equals(this.type)) {
if (orgRef.getOid() == null) {
newAssignment.setOrgRef(null);
;
} else {
ObjectReferenceType ref = new ObjectReferenceType();
ref.setOid(this.orgRef.getOid());
Expand Down
Expand Up @@ -146,11 +146,7 @@ public boolean isVisible(){
count++;
}
}
if (count == getModelObject().size()){
return false;
} else {
return true;
}
return count != getModelObject().size();
}
});
assignments.add(checkAll);
Expand Down
Expand Up @@ -69,8 +69,6 @@ protected void populateItem(Item item) {
public boolean isVisible(){
BaseSortableDataProvider p = (BaseSortableDataProvider) GridViewComponent.this.getModelObject();
List<AssignmentEditorDto> l = p.getAvailableData();

if (l != null){}
return true;
}
});
Expand Down
Expand Up @@ -248,26 +248,25 @@ public WebMarkupContainer getTextWrapperComponent(){
}

protected void initButtons(ListItem<T> item, WebMarkupContainer parent) {
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); {
buttonGroup.setOutputMarkupId(true);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
buttonGroup.setOutputMarkupId(true);

AjaxLink<Void> remove = new AjaxLink<Void>(ID_REMOVE) {
AjaxLink<Void> remove = new AjaxLink<>(ID_REMOVE) {

@Override
public void onClick(AjaxRequestTarget target) {
removeValuePerformed(target, item.getModelObject());
}
};
@Override
public void onClick(AjaxRequestTarget target) {
removeValuePerformed(target, item.getModelObject());
}
};

remove.add(new VisibleEnableBehaviour() {
remove.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
return isRemoveButtonVisible();
}
});
buttonGroup.add(remove);
}
@Override
public boolean isVisible() {
return isRemoveButtonVisible();
}
});
buttonGroup.add(remove);

parent.add(buttonGroup);
}
Expand Down
Expand Up @@ -121,9 +121,6 @@ private ApprovalProcessExecutionInformationDto createApprovalProcessExecutionInf
opTask.getResult().recordFatalError(
createStringResource("SwitchableApprovalProcessPreviewsPanel.message.createApprovalProcess.fatalError", t.getMessage()).getString(), t);
}
if (WebComponentUtil.showResultInPage(result)) {
;
}
return rv;
}

Expand Down
Expand Up @@ -171,7 +171,6 @@ private void customInitLayout() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
getObjectListPanel().refreshTable(ReportOutputType.class, target);
;
}
});
reportTypeSelect.setOutputMarkupId(true);
Expand Down
Expand Up @@ -435,7 +435,6 @@ private void newTaskPerformed(String category, AjaxRequestTarget target) {

taskType.setCategory(category);
setResponsePage(new PageTaskAdd(taskType));
;
}

private void runTask(List<TaskType> tasks, AjaxRequestTarget target) {
Expand Down
Expand Up @@ -718,7 +718,7 @@ private TaskType createTask(TaskAddDto dto) throws SchemaException {
task.setThreadStopAction(dto.getThreadStop());
} else {
// fill-in default
if (dto.getRunUntilNodeDown() == true) {
if (dto.getRunUntilNodeDown()) {
task.setThreadStopAction(ThreadStopActionType.CLOSE);
} else {
task.setThreadStopAction(ThreadStopActionType.RESTART);
Expand Down
Expand Up @@ -4,7 +4,6 @@
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.web.page.admin.server.dto;

import com.evolveum.midpoint.prism.delta.ChangeType;
Expand Down Expand Up @@ -37,7 +36,7 @@ public class ActionsExecutedObjectsTableLineDto implements Comparable<ActionsExe
public static final String F_LAST_SUCCESS_TIMESTAMP = "lastSuccessTimestamp";
public static final String F_FAILURE_COUNT = "failureCount";

private static final QName TYPES_ORDER[] = {
private static final QName[] TYPES_ORDER = {
UserType.COMPLEX_TYPE, OrgType.COMPLEX_TYPE, RoleType.COMPLEX_TYPE, ShadowType.COMPLEX_TYPE,
ResourceType.COMPLEX_TYPE, ReportType.COMPLEX_TYPE
};
Expand Down
Expand Up @@ -579,10 +579,8 @@ public boolean hasBuckets() {
List<WorkBucketType> buckets = taskType.getWorkState().getBucket();
if (buckets.size() > 1) {
return true;
} else if (buckets.size() == 1 && buckets.get(0).getContent() != null) {
return true;
} else {
return false;
return buckets.size() == 1 && buckets.get(0).getContent() != null;
}
}

Expand Down
Expand Up @@ -357,13 +357,13 @@ protected void onSavePerformed(AjaxRequestTarget target) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save password changes", ex);
result.recordFatalError(getString("PageAbstractSelfCredentials.save.password.failed", ex.getMessage()), ex);
} finally {
result.computeStatusIfUnknown();;
result.computeStatusIfUnknown();
}

finishChangePassword(result, target);
}

protected void setEncryptedPasswordData(EncryptedDataType data){
protected void setEncryptedPasswordData(EncryptedDataType data) {
MyPasswordsDto dto = model.getObject();
ProtectedStringType password = dto.getPassword();
if (password != null){
Expand Down
Expand Up @@ -230,11 +230,7 @@ private VisibleEnableBehaviour getTabVisibleBehaviour(String viewType){
@Override
public boolean isVisible(){
if (SchemaConstants.OBJECT_COLLECTION_ROLE_CATALOG_URI.equals(viewType)){
if (StringUtils.isEmpty(getRoleCatalogOid())){
return false;
} else {
return true;
}
return !StringUtils.isEmpty(getRoleCatalogOid());
}

RoleManagementConfigurationType config = roleManagementConfigModel.getObject();
Expand Down
Expand Up @@ -134,23 +134,17 @@ public <O extends ObjectType, T extends ObjectType> boolean isAuthorized(String

@Override
public boolean supports(ConfigAttribute attribute) {
if (attribute instanceof SecurityConfig
return attribute instanceof SecurityConfig
// class name equals, because WebExpressionConfigAttribute is non public class
|| "org.springframework.security.web.access.expression.WebExpressionConfigAttribute".equals(attribute.getClass().getName())) {
return true;
} else {
return false;
}
|| "org.springframework.security.web.access.expression.WebExpressionConfigAttribute".equals(attribute.getClass().getName());
}

@Override
public boolean supports(Class<?> clazz) {
if (MethodInvocation.class.isAssignableFrom(clazz)) {
return true;
} else if (FilterInvocation.class.isAssignableFrom(clazz)) {
return true;
} else {
return false;
return FilterInvocation.class.isAssignableFrom(clazz);
}
}

Expand Down
Expand Up @@ -131,8 +131,9 @@ public static void configure(LoggingConfigurationType config, String version,
//Parse internal log
res.recordSuccess();
for (String internalLogLine : internalLog.split("\n")) {
if (internalLogLine.contains("|-ERROR"))
if (internalLogLine.contains("|-ERROR")) {
res.recordPartialError(internalLogLine);
}
res.appendDetail(internalLogLine);
}
LOGGER.trace("LogBack internal log:\n{}",internalLog);
Expand Down
Expand Up @@ -103,8 +103,9 @@ private static boolean applySubsystemProfiling(SystemConfigurationType systemCon
}

//Check the dump interval
if(profilingConfig.getDumpInterval() != null)
if(profilingConfig.getDumpInterval() != null) {
dumpInterval = profilingConfig.getDumpInterval();
}

performanceProfiling = checkXsdBooleanValue(profilingConfig.isPerformanceStatistics());
requestProfiling = checkXsdBooleanValue(profilingConfig.isRequestFilter());
Expand All @@ -120,9 +121,6 @@ private static boolean applySubsystemProfiling(SystemConfigurationType systemCon
}

private static boolean checkXsdBooleanValue(Boolean value){
if(value == null || !value)
return false;
else
return true;
return value != null && value;
}
}
Expand Up @@ -22,7 +22,7 @@ public interface RuntimeConfiguration {
* @return String name of component
*/

public String getComponentId();
String getComponentId();

/**
* Returns current component configuration in commons configuration structure
Expand All @@ -45,5 +45,5 @@ public interface RuntimeConfiguration {
*
* @return Commons configuration
*/
public Configuration getCurrentConfiguration();
Configuration getCurrentConfiguration();
}

0 comments on commit e410d69

Please sign in to comment.