Skip to content

Commit 8c1a343

Browse files
committed
Fix checkstyle errors
1 parent 599b27d commit 8c1a343

File tree

30 files changed

+250
-77
lines changed

30 files changed

+250
-77
lines changed

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ plugins {
77

88
apply plugin: 'idea'
99

10+
def configDir = new File(buildscript.sourceFile.parentFile, 'config')
11+
ext.checkstyleConfigDir = "$configDir/checkstyle"
12+
1013
allprojects {
1114
repositories {
1215
mavenCentral()
@@ -15,13 +18,20 @@ allprojects {
1518
}
1619

1720
apply plugin: 'java'
21+
apply plugin: 'checkstyle'
1822

1923
sourceCompatibility = 1.8
2024
targetCompatibility = 1.8
2125

2226
intellij {
2327
version intellijSdkVersion
2428
}
29+
30+
checkstyle {
31+
toolVersion = "7.0"
32+
configFile = new File(checkstyleConfigDir, "checkstyle.xml")
33+
configProperties.checkstyleConfigDir = checkstyleConfigDir
34+
}
2535
}
2636

2737
release {

config/checkstyle/checkstyle.xml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
Checkstyle configuration that checks the sun coding conventions from:
8+
- the Java Language Specification at
9+
http://java.sun.com/docs/books/jls/second_edition/html/index.html
10+
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
11+
- the Javadoc guidelines at
12+
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
13+
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
14+
- some best practices
15+
Checkstyle is very configurable. Be sure to read the documentation at
16+
http://checkstyle.sf.net (or in your downloaded distribution).
17+
Most Checks are configurable, be sure to consult the documentation.
18+
To completely disable a check, just comment it out or delete it from the file.
19+
Finally, it is worth reading the documentation.
20+
-->
21+
22+
<module name="Checker">
23+
<!--
24+
If you set the basedir property below, then all reported file
25+
names will be relative to the specified directory. See
26+
http://checkstyle.sourceforge.net/5.x/config.html#Checker
27+
<property name="basedir" value="${basedir}"/>
28+
-->
29+
<module name="SuppressionFilter">
30+
<property name="file" value="${checkstyleConfigDir}/suppression.xml"/>
31+
</module>
32+
33+
<property name="fileExtensions" value="java, properties, xml"/>
34+
35+
<!-- Checks whether files end with a new line. -->
36+
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
37+
<module name="NewlineAtEndOfFile"/>
38+
39+
<!-- Checks that property files contain the same keys. -->
40+
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
41+
<module name="Translation"/>
42+
43+
<!-- Checks for Size Violations. -->
44+
<!-- See http://checkstyle.sf.net/config_sizes.html -->
45+
<module name="FileLength"/>
46+
47+
<!-- Checks for whitespace -->
48+
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
49+
<module name="FileTabCharacter"/>
50+
51+
<!-- Miscellaneous other checks. -->
52+
<!-- See http://checkstyle.sf.net/config_misc.html -->
53+
<module name="RegexpSingleline">
54+
<property name="format" value="\s+$"/>
55+
<property name="minimum" value="0"/>
56+
<property name="maximum" value="0"/>
57+
<property name="message" value="Line has trailing spaces."/>
58+
</module>
59+
60+
<module name="TreeWalker">
61+
62+
<!-- Checks for Naming Conventions. -->
63+
<!-- See http://checkstyle.sf.net/config_naming.html -->
64+
<module name="ConstantName"/>
65+
<module name="LocalFinalVariableName"/>
66+
<module name="LocalVariableName"/>
67+
<module name="MemberName"/>
68+
<module name="MethodName"/>
69+
<module name="PackageName"/>
70+
<module name="ParameterName"/>
71+
<module name="StaticVariableName"/>
72+
<module name="TypeName"/>
73+
74+
<!-- Checks for imports -->
75+
<!-- See http://checkstyle.sf.net/config_import.html -->
76+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
77+
<module name="RedundantImport"/>
78+
<module name="UnusedImports">
79+
<property name="processJavadoc" value="false"/>
80+
</module>
81+
82+
<!-- Checks for Size Violations. -->
83+
<!-- See http://checkstyle.sf.net/config_sizes.html -->
84+
<module name="LineLength">
85+
<property name="max" value="160"/>
86+
</module>
87+
<module name="MethodLength"/>
88+
<module name="ParameterNumber"/>
89+
90+
<!-- Checks for whitespace -->
91+
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
92+
<module name="EmptyForIteratorPad"/>
93+
<module name="GenericWhitespace"/>
94+
<module name="MethodParamPad"/>
95+
<module name="NoWhitespaceAfter"/>
96+
<module name="NoWhitespaceBefore"/>
97+
<module name="OperatorWrap"/>
98+
<module name="ParenPad"/>
99+
<module name="TypecastParenPad"/>
100+
<module name="WhitespaceAfter"/>
101+
<module name="WhitespaceAround"/>
102+
103+
<!-- Modifier Checks -->
104+
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
105+
<module name="ModifierOrder"/>
106+
<module name="RedundantModifier"/>
107+
108+
<!-- Checks for blocks. You know, those {}'s -->
109+
<!-- See http://checkstyle.sf.net/config_blocks.html -->
110+
<module name="AvoidNestedBlocks"/>
111+
<module name="EmptyBlock"/>
112+
<module name="LeftCurly"/>
113+
<module name="NeedBraces"/>
114+
<module name="RightCurly"/>
115+
116+
<!-- Checks for common coding problems -->
117+
<!-- See http://checkstyle.sf.net/config_coding.html -->
118+
<module name="EmptyStatement"/>
119+
<module name="EqualsHashCode"/>
120+
<module name="IllegalInstantiation"/>
121+
<module name="InnerAssignment"/>
122+
<module name="MissingSwitchDefault"/>
123+
<module name="SimplifyBooleanExpression"/>
124+
<module name="SimplifyBooleanReturn"/>
125+
126+
<!-- Checks for class design -->
127+
<!-- See http://checkstyle.sf.net/config_design.html -->
128+
<module name="FinalClass"/>
129+
<module name="InterfaceIsType"/>
130+
<module name="VisibilityModifier">
131+
<property name="protectedAllowed" value="true"/>
132+
</module>
133+
134+
<!-- Miscellaneous other checks. -->
135+
<!-- See http://checkstyle.sf.net/config_misc.html -->
136+
<module name="ArrayTypeStyle"/>
137+
<module name="UpperEll"/>
138+
</module>
139+
</module>

config/checkstyle/suppression.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
5+
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
6+
7+
<suppressions>
8+
<suppress files="[\\/]gen[\\/]" checks="[a-zA-Z0-9]*"/>
9+
<suppress files="_CypherLexer.java" checks="[a-zA-Z0-9]*"/>
10+
<suppress files="DataSource.java" checks="VisibilityModifier"/>
11+
<suppress files="DataSourcesComponentState.java" checks="VisibilityModifier"/>
12+
</suppressions>

database/neo4j/src/main/java/com/neueda/jetbrains/plugin/graphdb/database/neo4j/bolt/data/Neo4jBoltNode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ public GraphPropertyContainer getPropertyContainer() {
4747

4848
@Override
4949
public boolean equals(Object o) {
50-
if (this == o) return true;
51-
if (o == null || getClass() != o.getClass()) return false;
50+
if (this == o) {
51+
return true;
52+
}
53+
if (o == null || getClass() != o.getClass()) {
54+
return false;
55+
}
5256
Neo4jBoltNode that = (Neo4jBoltNode) o;
5357
return Objects.equals(id, that.id);
5458
}

database/neo4j/src/main/java/com/neueda/jetbrains/plugin/graphdb/database/neo4j/bolt/data/Neo4jBoltRelationship.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ public GraphNode getEndNode() {
8888

8989
@Override
9090
public boolean equals(Object o) {
91-
if (this == o) return true;
92-
if (o == null || getClass() != o.getClass()) return false;
91+
if (this == o) {
92+
return true;
93+
}
94+
if (o == null || getClass() != o.getClass()) {
95+
return false;
96+
}
9397
Neo4jBoltRelationship that = (Neo4jBoltRelationship) o;
9498
return Objects.equals(id, that.id);
9599
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/CypherLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/**
77
88
*/
9-
public class CypherLanguage extends Language {
9+
public final class CypherLanguage extends Language {
1010

1111
public static final CypherLanguage INSTANCE = new CypherLanguage();
1212

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/file/CypherFileType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
1515
*/
16-
public class CypherFileType extends LanguageFileType {
16+
public final class CypherFileType extends LanguageFileType {
1717

1818
public static final CypherFileType INSTANCE = new CypherFileType();
1919

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/highlight/CypherSyntaxHighlighter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ private boolean isOperationTokenType(IElementType tokenType) {
121121
|| tokenType.equals(CypherTypes.OP_POW)
122122
|| tokenType.equals(CypherTypes.OP_QUESTIONSIGN)
123123
|| tokenType.equals(CypherTypes.OP_RANGE)
124-
|| tokenType.equals(CypherTypes.OP_REGEXMATCH)
125-
;
124+
|| tokenType.equals(CypherTypes.OP_REGEXMATCH);
126125
}
127126

128127
@NotNull

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/lang/CypherBraceMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
*/
1616
public class CypherBraceMatcher implements PairedBraceMatcher {
17-
private static BracePair[] PAIRS = {
17+
private static BracePair[] pairs = {
1818
new BracePair(CypherTypes.PARENTHESE_OPEN, CypherTypes.PARENTHESE_CLOSE, true),
1919
new BracePair(CypherTypes.BRACKET_SQUAREOPEN, CypherTypes.BRACKET_SQUARECLOSE, true),
2020
// todo: curly braces are a bit buggy?
@@ -23,7 +23,7 @@ public class CypherBraceMatcher implements PairedBraceMatcher {
2323

2424
@Override
2525
public BracePair[] getPairs() {
26-
return PAIRS;
26+
return pairs;
2727
}
2828

2929
@Override

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/references/CypherRefactoringSupportProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public boolean isMemberInplaceRenameAvailable(@NotNull PsiElement element, @Null
2121
return element instanceof CypherVariable
2222
|| element instanceof CypherLabelName
2323
|| element instanceof CypherRelTypeName
24-
|| element instanceof CypherPropertyKeyName
25-
;
24+
|| element instanceof CypherPropertyKeyName;
2625
}
2726
}

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/references/CypherReferenceBase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ protected <T extends CypherNamedElement> Collection<T> uniqueVariants(List<T> da
6363
String watName = name + "IntellijIdeaRulezzz";
6464

6565
// WAT check for "IntellijIdeaRulezzz" postfix
66-
if (this.name.equals(name) || this.name.equals(watName)) return;
66+
if (this.name.equals(name) || this.name.equals(watName)) {
67+
return;
68+
}
6769

6870
if (!variants.containsKey(name)) {
6971
variants.put(name, element);

language/cypher/src/main/java/com/neueda/jetbrains/plugin/graphdb/language/cypher/settings/CypherColorSettingsPage.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public SyntaxHighlighter getHighlighter() {
5555
@NotNull
5656
@Override
5757
public String getDemoText() {
58-
return "// This is .cyp file\n" +
59-
"MATCH (n:NodeLabel {name: \"Dmitry\"})\n" +
60-
"MATCH (n)-[:LIKES]->(cypherLanguage:Language)\n" +
61-
"WHERE /* block comment */ n.property =\"string value\"\n" +
62-
"SET n.calculatedProperty = 2 + 2 \n" +
63-
"SET n.functionProperty = toInt(\"1\")\n" +
64-
"SET n.arrayProperty = [1, 2, 3, 4]\n" +
65-
"RETURN *;\n";
58+
return "// This is .cyp file\n"
59+
+ "MATCH (n:NodeLabel {name: \"Dmitry\"})\n"
60+
+ "MATCH (n)-[:LIKES]->(cypherLanguage:Language)\n"
61+
+ "WHERE /* block comment */ n.property =\"string value\"\n"
62+
+ "SET n.calculatedProperty = 2 + 2 \n"
63+
+ "SET n.functionProperty = toInt(\"1\")\n"
64+
+ "SET n.arrayProperty = [1, 2, 3, 4]\n"
65+
+ "RETURN *;\n";
6666
}
6767

6868
@Nullable

ui/jetbrains/src/main/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/database/DatabaseManagerServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public GraphDatabaseApi getDatabaseFor(DataSource dataSource) {
1313
switch (dataSource.getDataSourceType()) {
1414
case NEO4J_BOLT:
1515
return new Neo4jBoltDatabase(dataSource.getConfiguration());
16+
default:
17+
throw new RuntimeException(String.format("Database for data source [%s] does not exists", dataSource.dataSourceType));
1618
}
17-
throw new RuntimeException(String.format("Database for data source [%s] does not exists", dataSource.dataSourceType));
1819
}
1920
}

ui/jetbrains/src/main/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/ui/console/graph/GraphPanel.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void showNodeData(GraphNode node, VisualItem item, MouseEvent e) {
108108
entityDetailsTreeModel.setRoot(root);
109109

110110
Enumeration childs = root.children();
111-
while(childs.hasMoreElements()) {
111+
while (childs.hasMoreElements()) {
112112
PatchedDefaultMutableTreeNode treeNode
113113
= (PatchedDefaultMutableTreeNode) childs.nextElement();
114114
entityDetailsTree.expandPath(new TreePath(treeNode.getPath()));
@@ -121,25 +121,26 @@ public void showRelationshipData(GraphRelationship relationship, VisualItem item
121121
entityDetailsTreeModel.setRoot(root);
122122

123123
Enumeration childs = root.children();
124-
while(childs.hasMoreElements()) {
124+
while (childs.hasMoreElements()) {
125125
PatchedDefaultMutableTreeNode treeNode
126126
= (PatchedDefaultMutableTreeNode) childs.nextElement();
127127
entityDetailsTree.expandPath(new TreePath(treeNode.getPath()));
128128
}
129129
}
130130

131131
public void showTooltip(GraphEntity entity, VisualItem item, MouseEvent e) {
132-
if (balloon != null && !balloon.isDisposed())
132+
if (balloon != null && !balloon.isDisposed()) {
133133
balloon.hide();
134+
}
134135

135136
balloonPopupBuilder.setTitle(getTooltipTitle(entity));
136137
balloonLabel.setText(getTooltipText(entity));
137138

138139
balloon = balloonPopupBuilder.createBalloon();
139140
Container panel = e.getComponent().getParent();
140141

141-
final int MAGIC_NUMBER = 15;
142-
int heightOffset = balloon.getPreferredSize().height / 2 + MAGIC_NUMBER;
142+
final int magicNumber = 15;
143+
int heightOffset = balloon.getPreferredSize().height / 2 + magicNumber;
143144

144145
int widthOffset;
145146
if (e.getX() > panel.getWidth() / 2) {

ui/jetbrains/src/main/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/ui/console/log/LogPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void printException(Exception exception) {
9999
newLine();
100100

101101
Throwable cause = exception.getCause();
102-
while(cause != null) {
102+
while (cause != null) {
103103
error(cause.getMessage());
104104
newLine();
105105
cause = cause.getCause();

ui/jetbrains/src/main/java/com/neueda/jetbrains/plugin/graphdb/jetbrains/ui/console/table/TablePanel.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
public class TablePanel {
2222

23+
public static final int MAX_WIDTH = 300;
2324
private final ValueConverter valueConverter;
2425
private QueryResultTableModel tableModel;
2526
private JBTable table;
@@ -81,7 +82,7 @@ private void updateColumnWidths() {
8182
for (int column = 0; column < table.getColumnCount(); column++) {
8283
TableColumn tableColumn = table.getColumnModel().getColumn(column);
8384
int preferredWidth = tableColumn.getMinWidth();
84-
int maxWidth = 300;
85+
int maxWidth = MAX_WIDTH;
8586

8687
for (int row = 0; row < table.getRowCount(); row++) {
8788
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
@@ -90,8 +91,8 @@ private void updateColumnWidths() {
9091
preferredWidth = Math.max(preferredWidth, width);
9192

9293
// We've exceeded the maximum width, no need to check other rows
93-
if (preferredWidth >= maxWidth) {
94-
preferredWidth = maxWidth;
94+
if (preferredWidth >= MAX_WIDTH) {
95+
preferredWidth = MAX_WIDTH;
9596
break;
9697
}
9798
}

0 commit comments

Comments
 (0)