Skip to content

Commit

Permalink
IGNITE-16932 Checkstyle RightCurly rule added (apache#10017)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov authored May 6, 2022
1 parent 755f534 commit 147e031
Show file tree
Hide file tree
Showing 304 changed files with 1,018 additions and 509 deletions.
2 changes: 1 addition & 1 deletion checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress checks="LeftCurly|EmptyLineSeparator|MethodParamPad|SingleSpaceSeparator"
<suppress checks="RightCurly|LeftCurly|EmptyLineSeparator|MethodParamPad|SingleSpaceSeparator"
files="BCrypt\.java|ConcurrentLinkedDeque8\.java"/>
<suppress checks="NoWhitespaceBefore" files="ConcurrentLinkedHashMap\.java"/>
<suppress checks="LineLength"
Expand Down
4 changes: 4 additions & 0 deletions checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@
<module name="Indentation" />

<module name="LeftCurly"/>

<module name="RightCurly">
<property name="option" value="alone" />
</module>
</module>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public static void main(String[] args) throws IOException {

System.out.println("\n>>> Accuracy " + accuracy);
System.out.println("\n>>> Test Error " + (1 - accuracy));
} finally {
}
finally {
if (dataCache != null)
dataCache.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ public static void main(String[] args) throws IgniteCheckedException, IOExceptio
}

System.out.println(">>> Example completed.");
} finally {
}
finally {
cache.query(new SqlFieldsQuery("DROP TABLE titanic_train"));
cache.query(new SqlFieldsQuery("DROP TABLE titanic_test"));
cache.destroy();
}
} finally {
}
finally {
System.out.flush();
}
}
Expand Down Expand Up @@ -210,7 +212,8 @@ private static void insertToCache(IgniteCache<?, ?> cache, List<String> train, S
private static Integer parseInteger(String value) {
try {
return Integer.valueOf(value);
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
return 0;
}
}
Expand All @@ -219,7 +222,8 @@ private static Integer parseInteger(String value) {
private static Double parseDouble(String value) {
try {
return Double.valueOf(value);
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
return 0.0;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public IgniteCache<Integer, Vector> fillCacheWith(MLSandboxDatasets dataset) thr
try {
if (cells[i].isEmpty()) data[i] = Double.NaN;
else data[i] = Double.valueOf(cells[i]);
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
try {
data[i] = format.parse(cells[i]).doubleValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ private static void blockingListen(IgniteFuture future) throws Exception {
ab.set(true);
ab.notifyAll();
}
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ private void advance() throws IgniteCheckedException {

next = r;
break;
} else
}
else
cur = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@ static List<Expression> fromInternal(Class<?>[] targetTypes,
if (targetTypes.length == expressions.size()) {
for (int i = 0; i < expressions.size(); i++)
list.add(fromInternal(expressions.get(i), targetTypes[i]));
} else {
}
else {
int j = 0;
for (int i = 0; i < expressions.size(); i++) {
Class<?> type;
if (!targetTypes[j].isArray()) {
type = targetTypes[j];
j++;
} else
}
else
type = targetTypes[j].getComponentType();

list.add(fromInternal(expressions.get(i), type));
Expand Down Expand Up @@ -430,14 +432,16 @@ static List<Expression> convertAssignableTypes(Class<?>[] targetTypes,
if (targetTypes.length == arguments.size()) {
for (int i = 0; i < arguments.size(); i++)
list.add(convertAssignableType(arguments.get(i), targetTypes[i]));
} else {
}
else {
int j = 0;
for (Expression argument: arguments) {
Class<?> type;
if (!targetTypes[j].isArray()) {
type = targetTypes[j];
j++;
} else
}
else
type = targetTypes[j].getComponentType();

list.add(convertAssignableType(argument, type));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,8 @@ private CommonFieldGetter(Expression hnd_, Expression row_, RelDataType rowType)
if (desiredType == null) {
desiredType = fieldType;
fieldType = Object.class;
} else if (fieldType != java.sql.Date.class
}
else if (fieldType != java.sql.Date.class
&& fieldType != java.sql.Time.class
&& fieldType != java.sql.Timestamp.class)
fieldType = Object.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2532,7 +2532,8 @@ private static CallImplementor createTableFunctionImplementor(final Method metho
Expressions.constant(call.getOperator().getName(), String.class));
expr = Expressions.call(queryable,
BuiltInMethod.QUERYABLE_AS_ENUMERABLE.method);
} else {
}
else {
expr = Expressions.call(expr,
BuiltInMethod.SCANNABLE_TABLE_SCAN.method,
translator.getRoot());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ public static List<RelCollation> project(RelMetadataQuery mq,
for (Ord<RexNode> project : Ord.<RexNode>zip(projects)) {
if (project.e instanceof RexInputRef) {
targets.put(((RexInputRef)project.e).getIndex(), project.i);
} else if (project.e instanceof RexCall) {
}
else if (project.e instanceof RexCall) {
final RexCall call = (RexCall)project.e;
final RexCallBinding binding =
RexCallBinding.create(Commons.typeFactory(input), call, inputCollations);
Expand Down Expand Up @@ -363,7 +364,8 @@ public static List<RelCollation> values(RelMetadataQuery mq,
Ordering<List<RexLiteral>> ordering;
if (pairs.isEmpty()) {
ordering = comparator;
} else {
}
else {
ordering = Util.last(pairs).right.compound(comparator);
}
pairs.add(Pair.of(fieldCollation, ordering));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ private static Double quotientForPercentage(
if (denominator == 0.0) {
// cap at 100%
return 1.0;
} else {
}
else {
return numerator / denominator;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public FragmentMapping fragmentMapping(RelNode rel, MappingQueryContext ctx) {
for (;;) {
try {
return sourceDistributionHandler.fragmentMapping(rel, this, ctx);
} catch (JaninoRelMetadataProvider.NoHandler e) {
}
catch (JaninoRelMetadataProvider.NoHandler e) {
sourceDistributionHandler = revise(e.relClass, IgniteMetadata.FragmentMappingMetadata.DEF);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ private RelNode convertMerge(SqlMerge call) {
int level2Idx =
((RexInputRef)level1InsertExprs.get(level1Idx)).getIndex();
projects.add(level2InsertExprs.get(level2Idx));
} else
}
else
projects.add(level1InsertExprs.get(level1Idx));
}
if (updateCall != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ public static <T> T compile(Class<T> interfaceType, String body) {

try {
compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
} catch (Exception e) {
}
catch (Exception e) {
throw new IllegalStateException(
"Unable to instantiate java compiler", e);
}
Expand All @@ -344,7 +345,8 @@ public static <T> T compile(Class<T> interfaceType, String body) {
cbe.setDebuggingInformation(true, true, true);

return (T)cbe.createInstance(new StringReader(body));
} catch (Exception e) {
}
catch (Exception e) {
throw new IgniteException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ else if (CassandraHelper.isHostsAvailabilityError(e))
}

return;
} catch (Throwable e) {
}
catch (Throwable e) {
error = e;

if (CassandraHelper.isTableAbsenceError(e)) {
Expand All @@ -507,13 +508,16 @@ else if (CassandraHelper.isHostsAvailabilityError(e))
}
else
return;
} else if (CassandraHelper.isHostsAvailabilityError(e)) {
}
else if (CassandraHelper.isHostsAvailabilityError(e)) {
if (handleHostsAvailabilityError(ses == null ? 0 : ses.generation, e, attempt, errorMsg))
statements.clear();
} else if (CassandraHelper.isPreparedStatementClusterError(e)) {
}
else if (CassandraHelper.isPreparedStatementClusterError(e)) {
handlePreparedStatementClusterError(prepStatement == null ? 0 : prepStatement.generation, e);
statements.clear();
} else {
}
else {
// For an error which we don't know how to handle, we will not try next attempts and terminate.
throw new IgniteException(errorMsg, e);
}
Expand All @@ -524,9 +528,11 @@ else if (CassandraHelper.isHostsAvailabilityError(e))

attempt++;
}
} catch (Throwable e) {
}
catch (Throwable e) {
error = e;
} finally {
}
finally {
decrementSessionRefs();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public static void main(String[] args) {

try {
CassandraHelper.dropTestKeyspaces();
} catch (Throwable e) {
}
catch (Throwable e) {
throw new RuntimeException("Failed to drop test keyspace: " + perSettings.getKeyspace(), e);
}

Expand All @@ -52,7 +53,8 @@ public static void main(String[] args) {

try {
CassandraHelper.executeWithAdminCredentials(perSettings.getKeyspaceDDLStatement());
} catch (Throwable e) {
}
catch (Throwable e) {
throw new RuntimeException("Failed to create test keyspace: " + perSettings.getKeyspace(), e);
}

Expand All @@ -62,7 +64,8 @@ public static void main(String[] args) {

try {
CassandraHelper.executeWithAdminCredentials(perSettings.getTableDDLStatement(perSettings.getTable()));
} catch (Throwable e) {
}
catch (Throwable e) {
throw new RuntimeException("Failed to create test table: " + perSettings.getTable(), e);
}

Expand All @@ -78,7 +81,8 @@ public static void main(String[] args) {

try {
CassandraHelper.executeWithAdminCredentials(statement);
} catch (Throwable e) {
}
catch (Throwable e) {
throw new RuntimeException("Failed to create test table index", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,15 @@ public void testGetColumns() throws Exception {
assertEquals(0, rs.getInt("NULLABLE"));
assertEquals(0, rs.getInt(11)); // nullable column by index
assertEquals("NO", rs.getString("IS_NULLABLE"));
} else if ("AGE".equals(name)) {
}
else if ("AGE".equals(name)) {
assertEquals(INTEGER, rs.getInt("DATA_TYPE"));
assertEquals("INTEGER", rs.getString("TYPE_NAME"));
assertEquals(0, rs.getInt("NULLABLE"));
assertEquals(0, rs.getInt(11)); // nullable column by index
assertEquals("NO", rs.getString("IS_NULLABLE"));
} else if ("ORGID".equals(name)) {
}
else if ("ORGID".equals(name)) {
assertEquals(INTEGER, rs.getInt("DATA_TYPE"));
assertEquals("INTEGER", rs.getString("TYPE_NAME"));
assertEquals(1, rs.getInt("NULLABLE"));
Expand Down Expand Up @@ -571,7 +573,8 @@ public void testGetColumns() throws Exception {
assertEquals(0, rs.getInt("NULLABLE"));
assertEquals(0, rs.getInt(11)); // nullable column by index
assertEquals("NO", rs.getString("IS_NULLABLE"));
} else if ("name".equals(name)) {
}
else if ("name".equals(name)) {
assertEquals(VARCHAR, rs.getInt("DATA_TYPE"));
assertEquals("VARCHAR", rs.getString("TYPE_NAME"));
assertEquals(1, rs.getInt("NULLABLE"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ public void testGetColumns() throws Exception {
assert rs.getInt("DATA_TYPE") == VARCHAR;
assert "VARCHAR".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == 1;
} else if ("AGE".equals(name) || "ORGID".equals(name)) {
}
else if ("AGE".equals(name) || "ORGID".equals(name)) {
assert rs.getInt("DATA_TYPE") == INTEGER;
assert "INTEGER".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == (primitivesInformationIsLostAfterStore ? 1 : 0);
Expand Down Expand Up @@ -276,7 +277,8 @@ public void testGetColumns() throws Exception {
assert rs.getInt("DATA_TYPE") == INTEGER;
assert "INTEGER".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == 0;
} else if ("name".equals(name)) {
}
else if ("name".equals(name)) {
assert rs.getInt("DATA_TYPE") == VARCHAR;
assert "VARCHAR".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,15 @@ public void testGetColumns() throws Exception {
assert rs.getInt("NULLABLE") == 0;
assert rs.getInt(11) == 0; // nullable column by index
assert rs.getString("IS_NULLABLE").equals("NO");
} else if ("ORGID".equals(name)) {
}
else if ("ORGID".equals(name)) {
assert rs.getInt("DATA_TYPE") == INTEGER;
assert "INTEGER".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == 1;
assert rs.getInt(11) == 1; // nullable column by index
assert rs.getString("IS_NULLABLE").equals("YES");
} else if ("AGE".equals(name)) {
}
else if ("AGE".equals(name)) {
assert rs.getInt("DATA_TYPE") == INTEGER;
assert "INTEGER".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == 0;
Expand Down Expand Up @@ -573,7 +575,8 @@ else if ("_VAL".equals(name)) {
assert rs.getInt("DATA_TYPE") == INTEGER;
assert "INTEGER".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == 0;
} else if ("name".equals(name)) {
}
else if ("name".equals(name)) {
assert rs.getInt("DATA_TYPE") == VARCHAR;
assert "VARCHAR".equals(rs.getString("TYPE_NAME"));
assert rs.getInt("NULLABLE") == 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ private void clearCaches() {
for (int i = 0; i < NODES_CNT; i++)
try {
grid(i).cache(PARTITIONED_CACHE_NAME).clear();
} catch (IgniteException e) {
}
catch (IgniteException e) {
log.error("Cache clear failed.", e);
}
}
Expand Down
Loading

0 comments on commit 147e031

Please sign in to comment.