Skip to content

Commit

Permalink
Merge pull request #3571 from immmus/code_smells_from_sonar
Browse files Browse the repository at this point in the history
# Fixed some code smells from sonar
  • Loading branch information
planetf1 committed Oct 2, 2020
2 parents 63073c4 + fdf52eb commit 7b019d2
Show file tree
Hide file tree
Showing 54 changed files with 408 additions and 561 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.Map;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class OpenMetadataConformanceWorkbenchWorkPad
protected String tutType;
protected int maxPageSize;

protected Boolean workbenchComplete;
protected boolean workbenchComplete;

protected List<OpenMetadataConformanceTestEvidence> testEvidenceList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class OpenMetadataTestCase
/*
* Enumerated type for control of multi-phase tests
*/
public static enum TestPhase {
public enum TestPhase {
SEED,
EXECUTE,
CLEAN
Expand Down Expand Up @@ -66,8 +66,6 @@ public OpenMetadataTestCase(OpenMetadataConformanceWorkbenchWorkPad workPad,
Integer defaultProfileId,
Integer defaultRequirementId)
{
final String methodName = "OpenMetadataTestCase";

this.testCaseId = testCaseId;
this.testCaseName = testCaseName;
this.testCaseDescriptionURL = documentationRootURL + workPad.getWorkbenchId() + "/test-cases/" + testCaseId + "-test-case.md";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class AssertionFailureException extends ConformanceException
{
private static final long serialVersionUID = 1L;

private String assertionId;
private final String assertionId;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class CaughtException extends ConformanceException
{
private static final long serialVersionUID = 1L;

Throwable caughtException;
private final Throwable caughtException;

/**
* The constructor captures the context of the exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.odpi.openmetadata.conformance.beans.OpenMetadataConformanceWorkbenchResults;
import org.odpi.openmetadata.conformance.beans.OpenMetadataConformanceWorkbenchStatus;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ private static synchronized void setNewInstanceForJVM(String
*/
private static synchronized ConformanceServicesInstance getInstanceForJVM(String serverName)
{
ConformanceServicesInstance instance = instanceMap.get(serverName);

return instance;
return instanceMap.get(serverName);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,28 @@ private PrimitivePropertyValue getPrimitivePropertyValue(String propertyN
propertyValue.setPrimitiveValue(true);
break;
case OM_PRIMITIVE_TYPE_SHORT:
propertyValue.setPrimitiveValue(new Short("34"));
propertyValue.setPrimitiveValue(Short.valueOf("34"));
break;
case OM_PRIMITIVE_TYPE_BYTE:
propertyValue.setPrimitiveValue(new Byte("7"));
propertyValue.setPrimitiveValue(Byte.valueOf("7"));
break;
case OM_PRIMITIVE_TYPE_CHAR:
propertyValue.setPrimitiveValue(new Character('o'));
propertyValue.setPrimitiveValue('o');
break;
case OM_PRIMITIVE_TYPE_LONG:
propertyValue.setPrimitiveValue(new Long(2452));
propertyValue.setPrimitiveValue(2452L);
break;
case OM_PRIMITIVE_TYPE_FLOAT:
propertyValue.setPrimitiveValue(new Float(245332));
propertyValue.setPrimitiveValue(245332f);
break;
case OM_PRIMITIVE_TYPE_DOUBLE:
propertyValue.setPrimitiveValue(new Double(2459992));
propertyValue.setPrimitiveValue(2459992d);
break;
case OM_PRIMITIVE_TYPE_BIGDECIMAL:
propertyValue.setPrimitiveValue(new Double(245339992));
propertyValue.setPrimitiveValue(245339992d);
break;
case OM_PRIMITIVE_TYPE_BIGINTEGER:
propertyValue.setPrimitiveValue(new Double(245559992));
propertyValue.setPrimitiveValue(245559992d);
break;
case OM_PRIMITIVE_TYPE_UNKNOWN:
break;
Expand Down Expand Up @@ -408,11 +408,6 @@ private PrimitivePropertyValue getPrimitivePropertyValue(String propertyN
propertyValue.setPrimitiveValue((double)(2459992));
break;
case OM_PRIMITIVE_TYPE_BIGDECIMAL:
if (distinct)
propertyValue.setPrimitiveValue((double)(245339992+instanceCount)); // instanceCount is never 0 for distinct cases
else
propertyValue.setPrimitiveValue((double)(245339992));
break;
case OM_PRIMITIVE_TYPE_BIGINTEGER:
if (distinct)
propertyValue.setPrimitiveValue((double)(245339992+instanceCount)); // instanceCount is never 0 for distinct cases
Expand Down Expand Up @@ -447,12 +442,9 @@ protected InstanceProperties getPropertiesForInstance(List<TypeDefAttribute> ty
AttributeTypeDef attributeType = typeDefAttribute.getAttributeType();
AttributeTypeDefCategory category = attributeType.getCategory();

switch(category)
{
case PRIMITIVE:
PrimitiveDef primitiveDef = (PrimitiveDef)attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
break;
if (category == AttributeTypeDefCategory.PRIMITIVE) {
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
}
}

Expand Down Expand Up @@ -494,12 +486,9 @@ protected InstanceProperties getAllPropertiesForInstance(String userId, TypeDef
AttributeTypeDef attributeType = typeDefAttribute.getAttributeType();
AttributeTypeDefCategory category = attributeType.getCategory();

switch(category)
{
case PRIMITIVE:
PrimitiveDef primitiveDef = (PrimitiveDef)attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
break;
if (category == AttributeTypeDefCategory.PRIMITIVE) {
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
}
}

Expand Down Expand Up @@ -538,12 +527,9 @@ protected InstanceProperties generatePropertiesForInstance(String userId, List<
AttributeTypeDefCategory category = attributeType.getCategory();
boolean attrUnique = typeDefAttribute.isUnique();

switch(category)
{
case PRIMITIVE:
PrimitiveDef primitiveDef = (PrimitiveDef)attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef, attrUnique, instanceCount));
break;
if (category == AttributeTypeDefCategory.PRIMITIVE) {
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef, attrUnique, instanceCount));
}
}

Expand Down Expand Up @@ -586,11 +572,9 @@ protected InstanceProperties getAllUniquePropertiesForInstance(String userId, T
AttributeTypeDefCategory category = attributeType.getCategory();

if (typeDefAttribute.isUnique()) {
switch (category) {
case PRIMITIVE:
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
break;
if (category == AttributeTypeDefCategory.PRIMITIVE) {
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
}
}
}
Expand Down Expand Up @@ -635,11 +619,9 @@ protected InstanceProperties getMinPropertiesForInstance(String userId, TypeDef
if (attributeCardinality == AttributeCardinality.AT_LEAST_ONE_ORDERED ||
attributeCardinality == AttributeCardinality.AT_LEAST_ONE_UNORDERED) {

switch (category) {
case PRIMITIVE:
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
break;
if (category == AttributeTypeDefCategory.PRIMITIVE) {
PrimitiveDef primitiveDef = (PrimitiveDef) attributeType;
propertyMap.put(attributeName, this.getPrimitivePropertyValue(attributeName, primitiveDef));
}
}
}
Expand Down
Loading

0 comments on commit 7b019d2

Please sign in to comment.