Skip to content

Commit

Permalink
The new PMD plugin is strict about simplifying boolean returns
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Apr 3, 2015
1 parent 4387055 commit 3309231
Show file tree
Hide file tree
Showing 141 changed files with 259 additions and 908 deletions.
12 changes: 2 additions & 10 deletions core/src/main/java/org/apache/cxf/common/util/PropertyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ public static boolean isTrue(Object property) {
return false;
}

if (Boolean.TRUE.equals(property) || "true".equalsIgnoreCase(property.toString())) {
return true;
}

return false;
return Boolean.TRUE.equals(property) || "true".equalsIgnoreCase(property.toString());
}

/**
Expand All @@ -85,11 +81,7 @@ public static boolean isFalse(Object property) {
return false;
}

if (Boolean.FALSE.equals(property) || "false".equalsIgnoreCase(property.toString())) {
return true;
}

return false;
return Boolean.FALSE.equals(property) || "false".equalsIgnoreCase(property.toString());
}

public static Long getLong(Message message, String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ public static boolean isEmpty(List<String> list) {
if (list == null || list.size() == 0) {
return true;
}
if (list.size() == 1 && isEmpty(list.get(0))) {
return true;
}
return false;
return list.size() == 1 && isEmpty(list.get(0));
}

public static String diff(String str1, String str2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ public void handleMessage(Message message) {

protected boolean isHttpVerbSupported(Message message) {
if (isGET(message)) {
if (isRequestor(message)
&& MessageUtils.isTrue(message.getContextualProperty(FI_GET_SUPPORTED))) {
return true;
}
return false;
return isRequestor(message)
&& MessageUtils.isTrue(message.getContextualProperty(FI_GET_SUPPORTED));
} else {
return true;
}
Expand Down
7 changes: 2 additions & 5 deletions core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,13 @@ private static XMLInputFactory createWoodstoxFactory() {
private static boolean setRestrictionProperties(XMLInputFactory factory) {
//For now, we can only support Woodstox 4.2.x and newer as none of the other
//stax parsers support these settings
if (setProperty(factory, "com.ctc.wstx.maxAttributesPerElement", maxAttributeCount)
return setProperty(factory, "com.ctc.wstx.maxAttributesPerElement", maxAttributeCount)
&& setProperty(factory, "com.ctc.wstx.maxAttributeSize", maxAttributeSize)
&& setProperty(factory, "com.ctc.wstx.maxChildrenPerElement", innerElementCountThreshold)
&& setProperty(factory, "com.ctc.wstx.maxElementCount", maxElementCount)
&& setProperty(factory, "com.ctc.wstx.maxElementDepth", innerElementLevelThreshold)
&& setProperty(factory, "com.ctc.wstx.maxCharacters", maxXMLCharacters)
&& setProperty(factory, "com.ctc.wstx.maxTextLength", maxTextLength)) {
return true;
}
return false;
&& setProperty(factory, "com.ctc.wstx.maxTextLength", maxTextLength);
}

private static boolean setProperty(XMLInputFactory f, String p, Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,8 @@ private boolean isDefaultNamespaceRedefined(String uri) {
}

private boolean matchesDropped(boolean shallow) {
if ((dropDepth > 0 && dropDepth <= currentDepth)
|| (shallow && (elementsStack.size() > 0 && dropElements.contains(elementsStack.get(0))))) {
return true;
}
return false;
return (dropDepth > 0 && dropDepth <= currentDepth)
|| (shallow && (elementsStack.size() > 0 && dropElements.contains(elementsStack.get(0))));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ private boolean isJaxWsServiceInterface(Class<?> cls) {
if (cls == null) {
return false;
}
if (null != cls.getAnnotation(WebService.class)) {
return true;
}
return false;
return null != cls.getAnnotation(WebService.class);
}

public boolean isBound() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,7 @@ public boolean equals(Object other) {
return false;
}

if (!ObjectUtils.equals(that.getAddress(), address)) {
return false;
}

return true;
return ObjectUtils.equals(that.getAddress(), address);
}

// Required by JCA Spec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ public boolean equals(Object o) {

ManagedConnectionFactoryImpl that = (ManagedConnectionFactoryImpl)o;

if (!ObjectUtils.equals(that.getBusConfigURL(), busConfigURL)) {
return false;
}

return true;
return ObjectUtils.equals(that.getBusConfigURL(), busConfigURL);
}

public PrintWriter getLogWriter() throws ResourceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ private static boolean isJaxWsServiceInterface(Class<?> cls) {
if (cls == null) {
return false;
}
if (null != cls.getAnnotation(WebService.class)) {
return true;
}
return false;
return null != cls.getAnnotation(WebService.class);
}

public String getEjbServantBaseURL() {
Expand All @@ -165,10 +162,7 @@ public void setEjbServantBaseURL(String ejbServantBaseURL) {
}

private static boolean isNotNull(String value) {
if (value != null && !"".equals(value.trim())) {
return true;
}
return false;
return value != null && !"".equals(value.trim());
}

public WorkManager getWorkManager() {
Expand Down
4 changes: 2 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,12 @@
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>5.2.3</version>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>5.2.3</version>
<version>5.3.0</version>
</dependency>
</dependencies>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,7 @@ public static String getUniquePOAName(QName serviceName, String portName, String
}

public static boolean isIOR(String location) {
if ((location.startsWith("ior:")) || (location.startsWith("IOR:"))) {
return true;
}
return false;
return location.startsWith("ior:") || location.startsWith("IOR:");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ private synchronized void initializeSync() {
}

public boolean isMapped(PropertyDescriptor pd) {
if (pd.getReadMethod() == null) {
return false;
}

return true;
return pd.getReadMethod() != null;
}

protected void mapProperty(PropertyDescriptor pd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ public boolean equals(Object o) {

final BeanA beanA = (BeanA)o;

if ((propA != null) ? (!propA.equals(beanA.propA)) : (beanA.propA != null)) {
return false;
}

return true;
return !((propA != null) ? (!propA.equals(beanA.propA)) : (beanA.propA != null));
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ public boolean equals(Object o) {

final BeanB beanB = (BeanB)o;

if ((propB != null) ? (!propB.equals(beanB.propB)) : (beanB.propB != null)) {
return false;
}

return true;
return !((propB != null) ? (!propB.equals(beanB.propB)) : (beanB.propB != null));
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ public boolean equals(Object o) {

final BeanC beanC = (BeanC)o;

if ((propC != null) ? (!propC.equals(beanC.propC)) : (beanC.propC != null)) {
return false;
}

return true;
return !((propC != null) ? (!propC.equals(beanC.propC)) : (beanC.propC != null));
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public boolean equals(Object o) {
if (!Arrays.equals(result1, that.result1)) {
return false;
}
if (!Arrays.equals(result2, that.result2)) {
return false;
}

return true;
return Arrays.equals(result2, that.result2);
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ public boolean equals(Object o) {
if (child != null ? !child.equals(rootBean.child) : rootBean.child != null) {
return false;
}
if (id != null ? !id.equals(rootBean.id) : rootBean.id != null) {
return false;
}

return true;
return !(id != null ? !id.equals(rootBean.id) : rootBean.id != null);
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ public boolean equals(Object o) {
return false;
}

if (errorCode != that.errorCode) {
return false;
}

return true;
return errorCode == that.errorCode;
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ public boolean equals(Object o) {

final WS1ExtendedException that = (WS1ExtendedException)o;

if (extendedCode != that.extendedCode) {
return false;
}

return true;
return extendedCode == that.extendedCode;
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ public boolean equals(Object o) {
if (content != null ? !content.equals(that.content) : that.content != null) {
return false;
}
if (id != null ? !id.equals(that.id) : that.id != null) {
return false;
}

return true;
return !(id != null ? !id.equals(that.id) : that.id != null);
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public boolean equals(Object o) {
return false;
}

if (id != null ? !id.equals(that.id) : that.id != null) {
return false;
}

return true;
return !(id != null ? !id.equals(that.id) : that.id != null);
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public boolean equals(Object o) {
return false;
}

if (id != null ? !id.equals(that.id) : that.id != null) {
return false;
}

return true;
return !(id != null ? !id.equals(that.id) : that.id != null);
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ public boolean equals(Object o) {

final ContentBean1 that = (ContentBean1)o;

if (data1 != null ? !data1.equals(that.data1) : that.data1 != null) {
return false;
}

return true;
return !(data1 != null ? !data1.equals(that.data1) : that.data1 != null);
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ public boolean equals(Object o) {

final ContentBean2 that = (ContentBean2)o;

if (content2 != null ? !content2.equals(that.content2) : that.content2 != null) {
return false;
}

return true;
return !(content2 != null ? !content2.equals(that.content2) : that.content2 != null);
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,7 @@ private static List<Object> createList(Type genericType) {
}

private static boolean isList(Type cls) {
if (cls instanceof ParameterizedType) {
return true;
}
return false;
return cls instanceof ParameterizedType;
}
private static boolean isList(MessagePartInfo part) {
if (part.getTypeClass().isArray() && !part.getTypeClass().getComponentType().isPrimitive()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,12 @@ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotati

private boolean isSupported(Class<?> type, Type genericType, Annotation[] anns,
MediaType mt) {
if (mediaTypeSupported(mt)
return mediaTypeSupported(mt)
&& (WELL_KNOWN_MULTIPART_CLASSES.contains(type)
|| Collection.class.isAssignableFrom(type)
|| Map.class.isAssignableFrom(type) && type != MultivaluedMap.class
|| AnnotationUtils.getAnnotation(anns, Multipart.class) != null
|| MessageUtils.isTrue(mc.getContextualProperty(SUPPORT_TYPE_AS_MULTIPART)))) {
return true;
}
return false;
|| MessageUtils.isTrue(mc.getContextualProperty(SUPPORT_TYPE_AS_MULTIPART)));
}

protected void checkContentLength() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotat
}
}
}
if (mc != null && mc.get(MESSAGE_RESOURCE_PATH_PROPERTY) != null) {
return true;
}
return false;
return mc != null && mc.get(MESSAGE_RESOURCE_PATH_PROPERTY) != null;
}

private boolean classResourceSupported(Class<?> type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ public static boolean propogateException(Message m) {
return true;
}

if (Boolean.TRUE.equals(value) || "true".equalsIgnoreCase(value.toString())) {
return true;
}

return false;
return Boolean.TRUE.equals(value) || "true".equalsIgnoreCase(value.toString());
}


Expand Down
Loading

0 comments on commit 3309231

Please sign in to comment.