Skip to content
Permalink
Browse files
IGNITE-12893: Add support for SimplifyBooleanExpression checkstyle ru…
…le (#7670)
  • Loading branch information
Mmuzaf committed Apr 14, 2020
1 parent 54e3aa4 commit 6c01d3e6895fdb4408938d17f19440a4fb94cc08
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 37 deletions.
@@ -33,6 +33,9 @@
<module name="NewlineAtEndOfFile"/>

<module name="TreeWalker">
<!-- Coding Checks. See: https://checkstyle.sourceforge.io/config_coding.html -->
<module name="SimplifyBooleanExpression"/>

<!-- Import Checks. See: http://checkstyle.sourceforge.net/config_imports.html -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>
@@ -27,7 +27,7 @@ public class Target extends SuperTarget {

String res = super.methodA();

assert "SuperTarget.methodA()".equals(res) == true :
assert "SuperTarget.methodA()".equals(res) :
"Unexpected SuperTarget.methodA() apply result [res=" + res + ']';

return "Target.MethodA()";
@@ -37,7 +37,7 @@ public class Target extends SuperTarget {
@Override protected String methodB() {
String res = super.methodB();

assert "SuperTarget.methodC()".equals(res) == true:
assert "SuperTarget.methodC()".equals(res) :
"Unexpected SuperTarget.methodB() apply result [res=" + res + ']';

return res;
@@ -467,7 +467,7 @@ private void checkDefaultException(DeploymentMode depMode) {
stopGrid();
}

if (isException == false)
if (!isException)
fail("@Gridify method gridifyDefaultException(0) does not return any exception.");
}

@@ -35,7 +35,6 @@
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.EntryProcessorResult;
import javax.cache.processor.MutableEntry;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -588,7 +587,7 @@ private static IgniteInternalCache<Object, Object> cache(Ignite ignite,
boolean success = true;

for (IgniteInternalFuture<GridCacheRestResponse> f : cf.futures())
if ((Boolean)f.get().getResponse() != true)
if (!((Boolean)f.get().getResponse()))
success = false;

GridCacheRestResponse resp = new GridCacheRestResponse();
@@ -97,7 +97,7 @@ else if (msg.messageSize() < 3)

/** {@inheritDoc} */
@Override public ByteBuffer makeResponse(final GridRestResponse restRes, List<String> params) {
return ((Boolean)restRes.getResponse() == true ? GridRedisProtocolParser.toInteger("1")
return ((Boolean)restRes.getResponse() ? GridRedisProtocolParser.toInteger("1")
: GridRedisProtocolParser.toInteger("0"));
}
}
@@ -105,7 +105,7 @@ public GridRedisFlushCommandHandler(IgniteLogger log, GridRestProtocolHandler hn

/** {@inheritDoc} */
@Override public ByteBuffer makeResponse(final GridRestResponse restRes, List<String> params) {
return ((Boolean)restRes.getResponse() == true ? GridRedisProtocolParser.oKString()
return ((Boolean)restRes.getResponse() ? GridRedisProtocolParser.oKString()
: GridRedisProtocolParser.toGenericError("Failed to flush"));
}
}
@@ -628,7 +628,7 @@ public static int getPrefixLength(String filename) {
if (ch1 == ':') {
ch0 = Character.toUpperCase(ch0);
if (ch0 >= 'A' && ch0 <= 'Z') {
if (len == 2 || isSeparator(filename.charAt(2)) == false)
if (len == 2 || !isSeparator(filename.charAt(2)))
return 2;
return 3;
}
@@ -1322,7 +1322,7 @@ static String[] splitOnTokens(String text) {
if (array[i] == '?')
list.add("?");
else if (list.isEmpty() ||
i > 0 && list.get(list.size() - 1).equals("*") == false)
i > 0 && !list.get(list.size() - 1).equals("*"))
list.add("*");
} else
buffer.append(array[i]);
@@ -79,7 +79,7 @@ private BytePrintStream out(boolean release) {
while (grp != null && grp.getParent() != baseGrp)
grp = grp.getParent();

out = release == true ? streams.remove(grp) : streams.get(grp);
out = release ? streams.remove(grp) : streams.get(grp);

if (out == null) {
if (release)
@@ -74,8 +74,8 @@ public DeploymentResourceAdapter(String name, Class<?> rsrcCls, ClassLoader clsL

DeploymentResourceAdapter rsrc = (DeploymentResourceAdapter)obj;

return clsLdr.equals(rsrc.clsLdr) == true && name.equals(rsrc.name) == true &&
rsrcCls.equals(rsrc.rsrcCls) == true;
return clsLdr.equals(rsrc.clsLdr) && name.equals(rsrc.name) &&
rsrcCls.equals(rsrc.rsrcCls);
}

/** {@inheritDoc} */
@@ -110,7 +110,7 @@ private void checkNodes(Ignite g) throws Exception {
assertNotNull(v2);

// TODO GG-11148: can do assertSame if on-heap storage is implemented.
if (false && affinity(cache).mapKeyToNode(key).isLocal())
if (false)
assertSame(v1, v2);
else
assertEquals(v1, v2);
@@ -65,8 +65,8 @@
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
import org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList;
import org.apache.ignite.internal.processors.cache.persistence.tree.util.PageLockListener;
import org.apache.ignite.internal.processors.metric.impl.LongAdderMetric;
import org.apache.ignite.internal.processors.failure.FailureProcessor;
import org.apache.ignite.internal.processors.metric.impl.LongAdderMetric;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.GridRandom;
import org.apache.ignite.internal.util.GridStripedLock;
@@ -151,7 +151,7 @@ public static class FactorialTask extends ComputeTaskAdapter<Long, Long> {

for (int i = 0; i < arg; i++) {
// Recycle iterator.
if (iter.hasNext() == false)
if (!iter.hasNext())
iter = subgrid.iterator();

ClusterNode node = iter.next();
@@ -168,7 +168,7 @@ public Serializable execute() {
startSignal.countDown();

try {
if (startSignal.await(WAIT_TIME, TimeUnit.MILLISECONDS) == false)
if (!startSignal.await(WAIT_TIME, TimeUnit.MILLISECONDS))
fail();

synchronized (mux) {
@@ -153,7 +153,7 @@ public Serializable execute() {
startSignal.countDown();

try {
if (startSignal.await(WAIT_TIME, TimeUnit.MILLISECONDS) == false)
if (!startSignal.await(WAIT_TIME, TimeUnit.MILLISECONDS))
fail();

GridTaskSessionAttributeTestListener lsnr =
@@ -101,12 +101,12 @@ public void testLoader() throws Exception {

int i = 0;

while (found == false) {
while (!found) {
info("Attempt to find GridKernal MBean [num=" + i + ']');

Set<ObjectName> names = jmx.getMBeanServerConnection().queryNames(queryName, null);

if (names.isEmpty() == false) {
if (!names.isEmpty()) {
for (ObjectName objectName : names) {
info("Found MBean for node: " + objectName);

@@ -46,37 +46,37 @@ public void testCorrectMBeanInfo() throws Exception {

MBeanInfo info = mbean.getMBeanInfo();

assert info.getDescription().equals("MBeanDescription.") == true;
assert info.getDescription().equals("MBeanDescription.");

assert info.getOperations().length == 2;

for (MBeanOperationInfo opInfo : info.getOperations()) {
if (opInfo.getDescription().equals("MBeanOperation."))
assert opInfo.getSignature().length == 2;
else {
assert opInfo.getDescription().equals("MBeanSuperOperation.") == true;
assert opInfo.getDescription().equals("MBeanSuperOperation.");
assert opInfo.getSignature().length == 1;
}
}

for (MBeanParameterInfo paramInfo : info.getOperations()[0].getSignature()) {
if (paramInfo.getName().equals("ignored"))
assert paramInfo.getDescription().equals("MBeanOperationParameter1.") == true;
assert paramInfo.getDescription().equals("MBeanOperationParameter1.");
else {
assert paramInfo.getName().equals("someData") == true;
assert paramInfo.getDescription().equals("MBeanOperationParameter2.") == true;
assert paramInfo.getName().equals("someData");
assert paramInfo.getDescription().equals("MBeanOperationParameter2.");
}
}

assert info.getAttributes().length == 4 : "Expected 4 attributes but got " + info.getAttributes().length;

for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
if (attrInfo.isWritable() == false) {
assert (attrInfo.getDescription().equals("MBeanReadonlyGetter.") == true ||
if (!attrInfo.isWritable()) {
assert (attrInfo.getDescription().equals("MBeanReadonlyGetter.") ||
attrInfo.getDescription().equals("MBeanROGetter."));
}
else {
assert (attrInfo.getDescription().equals("MBeanWritableGetter.") == true ||
assert (attrInfo.getDescription().equals("MBeanWritableGetter.") ||
attrInfo.getDescription().equals("MBeanWritableIsGetter."));
}
}
@@ -36,7 +36,7 @@ public class JclLoggerTest {
public void testLogInitialize() {
log = new JclLogger(LogFactory.getLog(JclLoggerTest.class.getName()));

assert log.isInfoEnabled() == true;
assert log.isInfoEnabled();

log.info("This is 'info' message.");
log.warning("This is 'warning' message.");
@@ -43,7 +43,7 @@ public void setUp() throws Exception {
xml = GridTestUtils.resolveIgnitePath("modules/core/src/test/config/log4j-test.xml");

assert xml != null;
assert xml.exists() == true;
assert xml.exists();

log = new Log4JLogger(xml).getLogger(getClass());
}
@@ -62,7 +62,7 @@ private GridUriDeploymentDiscovery() {
throws IgniteSpiException {
Set<Class<? extends ComputeTask<?, ?>>> rsrcs = new HashSet<>();

if (file.exists() == false)
if (!file.exists())
return rsrcs;

GridUriDeploymentFileResourceLoader fileRsrcLdr = new GridUriDeploymentFileResourceLoader(clsLdr, file);
@@ -95,7 +95,7 @@ private GridUriDeploymentDiscovery() {
*/
private static void findResourcesInDirectory(GridUriDeploymentFileResourceLoader clsLdr, File dir,
Set<Class<? extends ComputeTask<?, ?>>> rsrcs) {
assert dir.isDirectory() == true;
assert dir.isDirectory();

for (File file : dir.listFiles()) {
if (file.isDirectory()) {
@@ -175,7 +175,7 @@ private static boolean verify0(InputStream in, PublicKey pubKey, boolean allSign
// Will return quietly if no problem.
verifyDigestsImplicitly(jin);

if (verifyEntry(jarEntry, manifest, pubKey, allSigned, true) == false)
if (!verifyEntry(jarEntry, manifest, pubKey, allSigned, true))
return false;

manifestFiles.remove(jarEntry.getName());
@@ -236,7 +236,7 @@ private static boolean verify0(String jarName, PublicKey pubKey, boolean allSign
// Will return quietly if no problem.
verifyDigestsImplicitly(jarFile.getInputStream(jarEntry));

if (verifyEntry(jarEntry, manifest, pubKey, allSigned, false) == false)
if (!verifyEntry(jarEntry, manifest, pubKey, allSigned, false))
return false;

manifestFiles.remove(jarEntry.getName());
@@ -285,16 +285,16 @@ private static boolean verifyEntry(JarEntry jarEntry, Manifest manifest, PublicK
inManifest = true;

// Don't ignore files not listed in manifest and META-INF directory.
if (allSigned == true && inManifest == false && entryName.toUpperCase().startsWith("META-INF/") == false)
if (allSigned && !inManifest && !entryName.toUpperCase().startsWith("META-INF/"))
return false;

// Looking at entries in manifest file.
if (inManifest) {
Certificate[] certs = makeCerts == false ? jarEntry.getCertificates() : getCertificates(jarEntry);
Certificate[] certs = !makeCerts ? jarEntry.getCertificates() : getCertificates(jarEntry);

boolean isSigned = certs != null && certs.length > 0;

if (isSigned == false || pubKey != null && findKeyInCertificates(pubKey, certs) == false)
if (!isSigned || pubKey != null && !findKeyInCertificates(pubKey, certs))
return false;
}

@@ -66,7 +66,7 @@ String parse() {
p++; // Skip ':'

if (at(p, n, '/')) {
if (at(p, n, '/') == true && at(p + 1, n, '/')) {
if (at(p, n, '/') && at(p + 1, n, '/')) {
p += 2;

// Seek authority.

0 comments on commit 6c01d3e

Please sign in to comment.