Skip to content

Commit f7b683f

Browse files
committed
[INTERNAL] checkstyle added & code cleanup
1 parent 76b5f7e commit f7b683f

37 files changed

+432
-215
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[![Plugin version](https://img.shields.io/jetbrains/plugin/d/10037-csv-plugin.svg)](https://plugins.jetbrains.com/plugin/10037-csv-plugin)
22
[![Build Status](https://travis-ci.org/SeeSharpSoft/intellij-csv-validator.svg?branch=master)](https://travis-ci.org/SeeSharpSoft/intellij-csv-validator)
33
[![Coverage Status](https://coveralls.io/repos/github/SeeSharpSoft/intellij-csv-validator/badge.svg?branch=master)](https://coveralls.io/github/SeeSharpSoft/intellij-csv-validator?branch=master)
4+
[![Known Vulnerabilities](https://snyk.io/test/github/SeeSharpSoft/intellij-csv-validator/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/SeeSharpSoft/intellij-csv-validator?targetFile=build.gradle)
5+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/97769359388e44bfb7101346d510fccf)](https://www.codacy.com/app/github_124/intellij-csv-validator?utm_source=github.com&utm_medium=referral&utm_content=SeeSharpSoft/intellij-csv-validator&utm_campaign=Badge_Grade)
46

57
# Lightweight CSV Plugin for JetBrains IDE family
68

checkstyle.xml

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

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvColumnInfo.java

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,104 +8,104 @@
88
public class CsvColumnInfo<T> {
99

1010
public class RowInfo {
11+
private final T myElement;
12+
private final int myRow;
13+
private final TextRange myTextRange;
14+
1115
RowInfo(T element, int row) {
1216
this(element, row, -1, -1);
1317
}
1418

1519
RowInfo(@NotNull T element, @NotNull int row, int startIndex, int endIndex) {
16-
this.element = element;
17-
this.row = row;
20+
this.myElement = element;
21+
this.myRow = row;
1822
if (startIndex <= endIndex && startIndex >= 0) {
19-
this.textRange = TextRange.create(startIndex, endIndex);
23+
this.myTextRange = TextRange.create(startIndex, endIndex);
2024
} else {
21-
this.textRange = null;
25+
this.myTextRange = null;
2226
}
2327
}
2428

25-
final T element;
26-
final int row;
27-
final TextRange textRange;
28-
2929
public T getElement() {
30-
return element;
30+
return myElement;
3131
}
3232

3333
public int getRowIndex() {
34-
return row;
34+
return myRow;
3535
}
3636

3737
public TextRange getTextRange() {
38-
return textRange;
38+
return myTextRange;
3939
}
4040

4141
@Override
4242
public int hashCode() {
43-
return element.hashCode();
43+
return myElement.hashCode();
4444
}
4545

4646
@Override
4747
public boolean equals(Object other) {
4848
if (!(other instanceof CsvColumnInfo.RowInfo)) {
4949
return false;
5050
}
51-
return this.element.equals(((RowInfo) other).element);
51+
return this.myElement.equals(((RowInfo) other).myElement);
5252
}
5353
}
5454

55-
private int columnIndex;
56-
private int maxLength;
57-
private Map<T, RowInfo> elementInfos;
58-
private T headerElement;
59-
private int size;
55+
private int myColumnIndex;
56+
private int myMaxLength;
57+
private Map<T, RowInfo> myElementInfos;
58+
private T myHeaderElement;
59+
private int mySize;
6060

6161
public CsvColumnInfo(int columnIndex, int maxLength) {
62-
this.columnIndex = columnIndex;
63-
this.maxLength = maxLength;
64-
this.elementInfos = new HashMap<>();
65-
this.headerElement = null;
66-
this.size = 0;
62+
this.myColumnIndex = columnIndex;
63+
this.myMaxLength = maxLength;
64+
this.myElementInfos = new HashMap<>();
65+
this.myHeaderElement = null;
66+
this.mySize = 0;
6767
}
6868

6969
public RowInfo getRowInfo(T element) {
70-
return elementInfos.get(element);
70+
return myElementInfos.get(element);
7171
}
7272

7373
public int getColumnIndex() {
74-
return columnIndex;
74+
return myColumnIndex;
7575
}
7676

7777
public int getMaxLength() {
78-
return maxLength;
78+
return myMaxLength;
7979
}
8080

8181
public void setMaxLength(int maxLength) {
82-
this.maxLength = maxLength;
82+
this.myMaxLength = maxLength;
8383
}
8484

8585
public int getSize() {
86-
return this.size;
86+
return this.mySize;
8787
}
8888

8989
public List<T> getElements() {
9090
List<T> result = new ArrayList<>(getSize());
9191
result.addAll(Collections.nCopies(getSize(), null));
92-
elementInfos.values()
93-
.forEach(rowInfo -> result.set(rowInfo.row, rowInfo.element));
92+
myElementInfos.values()
93+
.forEach(rowInfo -> result.set(rowInfo.myRow, rowInfo.myElement));
9494
return result;
9595
}
9696

9797
protected void put(@NotNull T element, @NotNull RowInfo rowInfo) {
98-
RowInfo previous = elementInfos.put(element, rowInfo);
99-
if (this.getSize() <= rowInfo.row) {
100-
this.size = rowInfo.row + 1;
98+
RowInfo previous = myElementInfos.put(element, rowInfo);
99+
if (this.getSize() <= rowInfo.myRow) {
100+
this.mySize = rowInfo.myRow + 1;
101101
}
102-
if (rowInfo.row == 0) {
103-
this.headerElement = element;
102+
if (rowInfo.myRow == 0) {
103+
this.myHeaderElement = element;
104104
}
105105
}
106106

107107
public void addElement(T element, int startIndex, int endIndex) {
108-
this.put(element, new RowInfo(element, elementInfos.size(), startIndex, endIndex));
108+
this.put(element, new RowInfo(element, myElementInfos.size(), startIndex, endIndex));
109109
}
110110

111111
public void addElement(T element) {
@@ -121,14 +121,14 @@ public void addElement(T element, int row) {
121121
}
122122

123123
public boolean containsElement(T needle) {
124-
return elementInfos.containsKey(needle);
124+
return myElementInfos.containsKey(needle);
125125
}
126126

127127
public boolean isHeaderElement(@NotNull T element) {
128128
return element.equals(getHeaderElement());
129129
}
130130

131131
public T getHeaderElement() {
132-
return this.headerElement;
132+
return this.myHeaderElement;
133133
}
134134
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvColumnInfoMap.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@
66

77
public class CsvColumnInfoMap<T> {
88

9-
private final Map<Integer, CsvColumnInfo<T>> infoColumnMap;
10-
private final Map<T, CsvColumnInfo<T>> reverseInfoColumnMap;
9+
private final Map<Integer, CsvColumnInfo<T>> myInfoColumnMap;
10+
private final Map<T, CsvColumnInfo<T>> myReverseInfoColumnMap;
1111

1212
public CsvColumnInfoMap(Map<Integer, CsvColumnInfo<T>> infoColumnMap) {
13-
this.infoColumnMap = infoColumnMap;
14-
this.reverseInfoColumnMap = new HashMap<>();
13+
this.myInfoColumnMap = infoColumnMap;
14+
this.myReverseInfoColumnMap = new HashMap<>();
1515
buildReverseMap();
1616
}
1717

1818
private void buildReverseMap() {
19-
for (CsvColumnInfo<T> columnInfo : this.infoColumnMap.values()) {
19+
for (CsvColumnInfo<T> columnInfo : this.myInfoColumnMap.values()) {
2020
for (T element : columnInfo.getElements()) {
21-
this.reverseInfoColumnMap.put(element, columnInfo);
21+
this.myReverseInfoColumnMap.put(element, columnInfo);
2222
}
2323
}
2424
}
2525

2626
public CsvColumnInfo<T> getColumnInfo(T element) {
27-
return reverseInfoColumnMap.get(element);
27+
return myReverseInfoColumnMap.get(element);
2828
}
2929

3030
public CsvColumnInfo<T> getColumnInfo(int columnIndex) {
31-
return infoColumnMap.get(columnIndex);
31+
return myInfoColumnMap.get(columnIndex);
3232
}
3333

3434
public CsvColumnInfo<T>.RowInfo getRowInfo(T element) {
@@ -37,6 +37,6 @@ public CsvColumnInfo<T>.RowInfo getRowInfo(T element) {
3737
}
3838

3939
public Map<Integer, CsvColumnInfo<T>> getColumnInfos() {
40-
return Collections.unmodifiableMap(this.infoColumnMap);
40+
return Collections.unmodifiableMap(this.myInfoColumnMap);
4141
}
4242
}

0 commit comments

Comments
 (0)