Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1937 - Validate indentation and unnecessary semicolons in checkstyle #2008

Merged
merged 13 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion code-style/checkstyle-idea/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,23 @@
<module name="IllegalImport">
<property name="illegalPkgs" value="org.junit.jupiter.api.Assertions"/>
</module>
<module name="Indentation">
<property name="id" value="indentation"/>
</module>
<module name="UnnecessarySemicolonAfterOuterTypeDeclaration">
<property name="id" value="unnecessarySemicolonAfterOuterTypeDeclaration"/>
</module>
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration">
<property name="id" value="unnecessarySemicolonAfterTypeMemberDeclaration"/>
</module>
<module name="UnnecessarySemicolonInEnumeration">
<property name="id" value="unnecessarySemicolonInEnumeration"/>
</module>
<module name="UnnecessarySemicolonInTryWithResources">
<property name="id" value="unnecessarySemicolonInTryWithResources"/>
</module>
</module>
<module name="UniqueProperties">
<property name="id" value="uniqueProperties"/>
</module>
</module>
</module>
15 changes: 15 additions & 0 deletions code-style/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,21 @@
<property name="illegalClasses"
value="^org\.junit\.jupiter\.api\.Assertions, ^org\.junit\.(?!jupiter|platform).+"/>
</module>
<module name="Indentation">
<property name="id" value="indentation"/>
</module>
<module name="UnnecessarySemicolonAfterOuterTypeDeclaration">
<property name="id" value="unnecessarySemicolonAfterOuterTypeDeclaration"/>
</module>
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration">
<property name="id" value="unnecessarySemicolonAfterTypeMemberDeclaration"/>
</module>
<module name="UnnecessarySemicolonInEnumeration">
<property name="id" value="unnecessarySemicolonInEnumeration"/>
</module>
<module name="UnnecessarySemicolonInTryWithResources">
<property name="id" value="unnecessarySemicolonInTryWithResources"/>
</module>
</module>
<module name="UniqueProperties">
<property name="id" value="uniqueProperties"/>
Expand Down
4 changes: 2 additions & 2 deletions code-style/eclipse-style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
Expand Down Expand Up @@ -339,7 +339,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,48 +48,44 @@ public class DrawDependencyGraph {
LayoutPaintable.BalloonRings balloonLayoutRings;
LayoutPaintable.RadialRings radialLayoutRings;

String instructions =
"<html>"
+ "<h3>Graph Transformation:</h3>"
+ "<ul>"
+ "<li>Mousewheel scales with a crossover value of 1.0.<p>"
+ " - scales the graph layout when the combined scale is greater than 1<p>"
+ " - scales the graph view when the combined scale is less than 1"
+ "<li>Mouse1+drag pans the graph"
+ "<li>Mouse1 double click on the background resets all transforms"
+ "</ul>"
+ "<h3>Vertex/Edge Selection:</h3>"
+ "<ul>"
+ "<li>Mouse1+MENU on a vertex or edge selects the vertex or edge and deselects any others"
+ "<li>Mouse1+MENU+Shift on a vertex toggles selection of the vertex"
+ "<li>Mouse1+MENU on a selected edge toggles selection of the edge"
+ "<li>Mouse1+MENU+drag elsewhere selects vertices in a region"
+ "<li>Mouse1+Shift+drag adds selection of vertices in a new region"
+ "</ul>"
+ "<h3>Vertex Transformation:</h3>"
+ "<ul>"
+ "<li>Mouse1+MENU+drag on a selected vertex moves all selected Vertices"
+ "</ul>"
+ "Note that MENU == Command on a Mac, MENU == CTRL on a PC"
+ "</html>";
String instructions = "<html>"
+ "<h3>Graph Transformation:</h3>"
+ "<ul>"
+ "<li>Mousewheel scales with a crossover value of 1.0.<p>"
+ " - scales the graph layout when the combined scale is greater than 1<p>"
+ " - scales the graph view when the combined scale is less than 1"
+ "<li>Mouse1+drag pans the graph"
+ "<li>Mouse1 double click on the background resets all transforms"
+ "</ul>"
+ "<h3>Vertex/Edge Selection:</h3>"
+ "<ul>"
+ "<li>Mouse1+MENU on a vertex or edge selects the vertex or edge and deselects any others"
+ "<li>Mouse1+MENU+Shift on a vertex toggles selection of the vertex"
+ "<li>Mouse1+MENU on a selected edge toggles selection of the edge"
+ "<li>Mouse1+MENU+drag elsewhere selects vertices in a region"
+ "<li>Mouse1+Shift+drag adds selection of vertices in a new region"
+ "</ul>"
+ "<h3>Vertex Transformation:</h3>"
+ "<ul>"
+ "<li>Mouse1+MENU+drag on a selected vertex moves all selected Vertices"
+ "</ul>"
+ "Note that MENU == Command on a Mac, MENU == CTRL on a PC"
+ "</html>";

public void drawGraph(GraphModel model) {
Graph<GraphNode, GraphEdge> g =
GraphTypeBuilder.<GraphNode, GraphEdge>directed().buildGraph();
Graph<GraphNode, GraphEdge> g = GraphTypeBuilder.<GraphNode, GraphEdge>directed().buildGraph();
model.getNodes().forEach(g::addVertex);
model.getEdges().forEach(edge -> g.addEdge(edge.getFrom(model), edge.getTo(model), edge));

VisualizationViewer<GraphNode, GraphEdge> vv =
VisualizationViewer.<GraphNode, GraphEdge>builder(g)
.build();
VisualizationViewer<GraphNode, GraphEdge> vv = VisualizationViewer.<GraphNode, GraphEdge>builder(g)
.build();

// use html to break long labels into multi-line and center-align the text
vv.getRenderContext().setVertexLabelFunction(v -> "<html><b><center>" +
v.toString().replaceAll("/", "/<br>"));

PickedNodeState picked = new PickedNodeState(model);
vv.getRenderContext().getSelectedVertexState().addItemListener(event ->
picked.updatePicked(vv.getRenderContext().getSelectedVertexState().getSelected()));
vv.getRenderContext().getSelectedVertexState().addItemListener(event -> picked.updatePicked(vv.getRenderContext().getSelectedVertexState().getSelected()));
vv.getRenderContext().setEdgeDrawPaintFunction(edge -> picked.calculateEdgeColor(edge, showTransitiveDependencies));
vv.getRenderContext().setArrowDrawPaintFunction(edge -> picked.calculateArrowColor(edge, showTransitiveDependencies));
vv.getRenderContext().setArrowFillPaintFunction(edge -> picked.calculateArrowColor(edge, showTransitiveDependencies));
Expand All @@ -103,35 +99,30 @@ public void drawGraph(GraphModel model) {

final JComboBox layoutComboBox = new JComboBox(combos);
layoutComboBox.addActionListener(
e ->
SwingUtilities.invokeLater(
() -> {
LayoutHelperDirectedGraphs.Layouts layoutBuilderType =
(LayoutHelperDirectedGraphs.Layouts) layoutComboBox.getSelectedItem();
LayoutAlgorithm.Builder layoutAlgorithmBuilder =
layoutBuilderType.getLayoutAlgorithmBuilder();
LayoutAlgorithm<GraphNode> layoutAlgorithm = layoutAlgorithmBuilder.build();
vv.removePreRenderPaintable(balloonLayoutRings);
vv.removePreRenderPaintable(radialLayoutRings);
layoutAlgorithm.setAfter(vv::scaleToLayout);
if (animateLayoutTransition.isSelected()) {
LayoutAlgorithmTransition.animate(vv, layoutAlgorithm, vv::scaleToLayout);
} else {
LayoutAlgorithmTransition.apply(vv, layoutAlgorithm, vv::scaleToLayout);
}
if (layoutAlgorithm instanceof BalloonLayoutAlgorithm) {
balloonLayoutRings =
new LayoutPaintable.BalloonRings(
vv, (BalloonLayoutAlgorithm) layoutAlgorithm);
vv.addPreRenderPaintable(balloonLayoutRings);
}
if (layoutAlgorithm instanceof RadialTreeLayoutAlgorithm) {
radialLayoutRings =
new LayoutPaintable.RadialRings(
vv, (RadialTreeLayoutAlgorithm) layoutAlgorithm);
vv.addPreRenderPaintable(radialLayoutRings);
}
}));
e -> SwingUtilities.invokeLater(
() -> {
LayoutHelperDirectedGraphs.Layouts layoutBuilderType = (LayoutHelperDirectedGraphs.Layouts) layoutComboBox.getSelectedItem();
LayoutAlgorithm.Builder layoutAlgorithmBuilder = layoutBuilderType.getLayoutAlgorithmBuilder();
LayoutAlgorithm<GraphNode> layoutAlgorithm = layoutAlgorithmBuilder.build();
vv.removePreRenderPaintable(balloonLayoutRings);
vv.removePreRenderPaintable(radialLayoutRings);
layoutAlgorithm.setAfter(vv::scaleToLayout);
if (animateLayoutTransition.isSelected()) {
LayoutAlgorithmTransition.animate(vv, layoutAlgorithm, vv::scaleToLayout);
} else {
LayoutAlgorithmTransition.apply(vv, layoutAlgorithm, vv::scaleToLayout);
}
if (layoutAlgorithm instanceof BalloonLayoutAlgorithm) {
balloonLayoutRings = new LayoutPaintable.BalloonRings(
vv, (BalloonLayoutAlgorithm) layoutAlgorithm);
vv.addPreRenderPaintable(balloonLayoutRings);
}
if (layoutAlgorithm instanceof RadialTreeLayoutAlgorithm) {
radialLayoutRings = new LayoutPaintable.RadialRings(
vv, (RadialTreeLayoutAlgorithm) layoutAlgorithm);
vv.addPreRenderPaintable(radialLayoutRings);
}
}));

layoutComboBox.setSelectedItem(LayoutHelperDirectedGraphs.Layouts.SUGIYAMA);

Expand Down
76 changes: 38 additions & 38 deletions java/cdk/src/main/java/sleeper/cdk/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,44 +152,44 @@ public static LogDriver createECSContainerLogDriver(Construct scope, InstancePro

private static RetentionDays getRetentionDays(int numberOfDays) {
switch (numberOfDays) {
case -1:
return RetentionDays.INFINITE;
case 1:
return RetentionDays.ONE_DAY;
case 3:
return RetentionDays.THREE_DAYS;
case 5:
return RetentionDays.FIVE_DAYS;
case 7:
return RetentionDays.ONE_WEEK;
case 14:
return RetentionDays.TWO_WEEKS;
case 30:
return RetentionDays.ONE_MONTH;
case 60:
return RetentionDays.TWO_MONTHS;
case 90:
return RetentionDays.THREE_MONTHS;
case 120:
return RetentionDays.FOUR_MONTHS;
case 150:
return RetentionDays.FIVE_MONTHS;
case 180:
return RetentionDays.SIX_MONTHS;
case 365:
return RetentionDays.ONE_YEAR;
case 400:
return RetentionDays.THIRTEEN_MONTHS;
case 545:
return RetentionDays.EIGHTEEN_MONTHS;
case 731:
return RetentionDays.TWO_YEARS;
case 1827:
return RetentionDays.FIVE_YEARS;
case 3653:
return RetentionDays.TEN_YEARS;
default:
throw new IllegalArgumentException("Invalid number of days; see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html for valid options");
case -1:
return RetentionDays.INFINITE;
case 1:
return RetentionDays.ONE_DAY;
case 3:
return RetentionDays.THREE_DAYS;
case 5:
return RetentionDays.FIVE_DAYS;
case 7:
return RetentionDays.ONE_WEEK;
case 14:
return RetentionDays.TWO_WEEKS;
case 30:
return RetentionDays.ONE_MONTH;
case 60:
return RetentionDays.TWO_MONTHS;
case 90:
return RetentionDays.THREE_MONTHS;
case 120:
return RetentionDays.FOUR_MONTHS;
case 150:
return RetentionDays.FIVE_MONTHS;
case 180:
return RetentionDays.SIX_MONTHS;
case 365:
return RetentionDays.ONE_YEAR;
case 400:
return RetentionDays.THIRTEEN_MONTHS;
case 545:
return RetentionDays.EIGHTEEN_MONTHS;
case 731:
return RetentionDays.TWO_YEARS;
case 1827:
return RetentionDays.FIVE_YEARS;
case 3653:
return RetentionDays.TEN_YEARS;
default:
throw new IllegalArgumentException("Invalid number of days; see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html for valid options");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public CreateCompactionJobs(ObjectFactory objectFactory,
}

public enum Mode {
STRATEGY, FORCE_ALL_FILES_AFTER_STRATEGY;
STRATEGY, FORCE_ALL_FILES_AFTER_STRATEGY
}

public void createJobs() throws StateStoreException, IOException, ObjectFactoryException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ private static String nthString(int n) {

private static byte[] nthByteArray(int n) {
return new byte[]{
(byte) (n / 128),
(byte) (n % 128)
(byte) (n / 128),
(byte) (n % 128)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public enum CompressionCodec {
LZO,
BROTLI,
LZ4,
ZSTD;
ZSTD
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,13 @@ protected IngestResult ingestRecords(StateStore stateStore, List<Record> records
return ingestRecords.close();
}

protected IngestResult ingestFromRecordIterator(Schema schema, StateStore stateStore, Iterator<Record> iterator)
throws StateStoreException, IteratorException, IOException {
protected IngestResult ingestFromRecordIterator(Schema schema, StateStore stateStore, Iterator<Record> iterator) throws StateStoreException, IteratorException, IOException {
tableProperties.setSchema(schema);
IngestFactory factory = createIngestFactory(stateStore);
return factory.ingestFromRecordIterator(tableProperties, iterator);
}

protected IngestResult ingestFromRecordIterator(StateStore stateStore, Iterator<Record> iterator)
throws StateStoreException, IteratorException, IOException {
protected IngestResult ingestFromRecordIterator(StateStore stateStore, Iterator<Record> iterator) throws StateStoreException, IteratorException, IOException {
IngestFactory factory = createIngestFactory(stateStore);
return factory.ingestFromRecordIterator(tableProperties, iterator);
}
Expand All @@ -135,12 +133,12 @@ protected List<Record> readRecords(FileReference... fileReferences) {

protected List<Record> readRecords(Stream<String> filenames) {
return filenames.map(filename -> {
try {
return readRecordsFromParquetFile(filename, schema);
} catch (Exception e) {
throw new RuntimeException(e);
}
})
try {
return readRecordsFromParquetFile(filename, schema);
} catch (Exception e) {
throw new RuntimeException(e);
}
})
.flatMap(List::stream)
.collect(Collectors.toList());
}
Expand Down
Loading
Loading