Skip to content

Commit ff44f24

Browse files
ahornaceVladimir Kotal
authored andcommitted
Add additional checkstyle checks (#2896)
1 parent 345b06a commit ff44f24

File tree

224 files changed

+2261
-2197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+2261
-2197
lines changed

dev/checkstyle/style.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,33 @@
1212
<module name="FileLength"/>
1313
<module name="FileTabCharacter"/>
1414
<module name="TreeWalker">
15+
<module name="JavadocStyle"/>
1516
<module name="AvoidStarImport">
1617
<property name="allowStaticMemberImports" value="true"/>
1718
</module>
1819
<module name="RedundantImport"/>
1920
<module name="UnusedImports"/>
21+
<module name="LineLength">
22+
<property name="max" value="150"/>
23+
</module>
2024
<module name="MethodLength">
2125
<property name="max" value="200"/>
2226
</module>
2327
<module name="AnonInnerLength">
2428
<property name="max" value="60"/>
2529
</module>
2630
<module name="ParameterNumber"/>
31+
<module name="EmptyBlock"/>
32+
<module name="LeftCurly"/>
2733
<module name="NeedBraces"/>
34+
<module name="RightCurly"/>
2835
<module name="GenericWhitespace"/>
2936
<module name="MethodParamPad"/>
3037
<module name="NoWhitespaceAfter"/>
38+
<module name="NoWhitespaceBefore"/>
39+
<module name="TypecastParenPad"/>
40+
<module name="WhitespaceAfter"/>
41+
<module name="WhitespaceAround"/>
3142
<module name="SuppressionCommentFilter">
3243
<property name="offCommentFormat" value="&lt;editor-fold defaultstate=&quot;collapsed&quot; desc=&quot;Generated Code&quot;&gt;"/>
3344
<property name="onCommentFormat" value="&lt;/editor-fold&gt;"/>
@@ -39,6 +50,8 @@
3950
<module name="SimplifyBooleanExpression"/>
4051
<module name="SimplifyBooleanReturn"/>
4152

53+
<module name="HideUtilityClassConstructor"/>
54+
4255
<module name="ArrayTypeStyle"/>
4356
<module name="UpperEll"/>
4457
</module>

dev/checkstyle/suppressions.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ Portions Copyright (c) 2018-2019, Chris Fraire <[email protected]>.
4040
|Context\.java|HistoryContext\.java|Suggester\.java" />
4141

4242
<suppress checks="MethodLength" files="Indexer\.java" />
43+
44+
<suppress checks="JavadocStyle" files="MellonHeaderDecoder\.java|CustomSloppyPhraseScorer\.java|
45+
|PhrasePositions\.java" />
46+
47+
<suppress checks="LineLength" files="CustomSloppyPhraseScorer\.java" />
48+
49+
<suppress checks="EmptyBlock" files="JFlexNonXref\.java|JavaClassAnalyzer\.java|JFlexXref\.java|Util\.java|
50+
|ClearCaseRepository\.java" />
51+
52+
<suppress checks="WhitespaceAround" files="CustomPhraseQuery\.java|PhrasePositions\.java|
53+
|CustomSloppyPhraseScorer\.java" />
54+
55+
<suppress checks="WhitespaceAfter" files="CustomSloppyPhraseScorer\.java|CustomPhraseQuery\.java" />
4356
</suppressions>

opengrok-indexer/src/main/java/org/opengrok/indexer/Info.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public final class Info {
5353
}
5454

5555
/**
56-
* get major version
56+
* Get major version.
5757
*
5858
* @return major version
5959
*/
@@ -62,7 +62,7 @@ public static String getVersion() {
6262
}
6363

6464
/**
65-
* get full version (product vMajor revMinor)
65+
* Get full version (product vMajor revMinor).
6666
*
6767
* @return full version
6868
*/
@@ -71,7 +71,7 @@ public static String getFullVersion() {
7171
}
7272

7373
/**
74-
* get minor version
74+
* Get minor version.
7575
*
7676
* @return minor version
7777
*/
@@ -81,7 +81,7 @@ public static String getRevision() {
8181

8282

8383
/**
84-
* get short minor version
84+
* Get short minor version.
8585
*
8686
* @return short minor version
8787
*/

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/AbstractAnalyzer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
import org.opengrok.indexer.configuration.Project;
3535

3636
/**
37-
* Created on September 21, 2005
3837
*
3938
* @author Chandan
4039
*/
4140
public abstract class AbstractAnalyzer extends Analyzer {
41+
4242
public static final Reader DUMMY_READER = new StringReader("");
4343
protected AnalyzerFactory factory;
4444
// you analyzer HAS to override this to get proper symbols in results
@@ -117,23 +117,23 @@ public abstract void analyze(Document doc, StreamSource src, Writer xrefOut)
117117
*/
118118
public enum Genre {
119119
/**
120-
* xrefed - line numbered context
120+
* xrefed - line numbered context.
121121
*/
122122
PLAIN("p"),
123123
/**
124-
* xrefed - summarizer context
124+
* xrefed - summarizer context.
125125
*/
126126
XREFABLE("x"),
127127
/**
128-
* not xrefed - no context - used by diff/list
128+
* not xrefed - no context - used by diff/list.
129129
*/
130130
IMAGE("i"),
131131
/**
132-
* not xrefed - no context
132+
* not xrefed - no context.
133133
*/
134134
DATA("d"),
135135
/**
136-
* not xrefed - summarizer context from original file
136+
* not xrefed - summarizer context from original file.
137137
*/
138138
HTML("h");
139139
private final String typeName;

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/AnalyzerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public final AbstractAnalyzer.Genre getGenre() {
146146
}
147147

148148
/**
149-
* The user friendly name of this analyzer
149+
* The user friendly name of this analyzer.
150150
*
151151
* @return a genre
152152
*/

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/AnalyzerGuru.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,13 @@ public class AnalyzerGuru {
128128

129129
/**
130130
* The maximum number of characters (multi-byte if a BOM is identified) to
131-
* read from the input stream to be used for magic string matching
131+
* read from the input stream to be used for magic string matching.
132132
*/
133133
private static final int OPENING_MAX_CHARS = 100;
134134

135135
/**
136136
* Set to 16K -- though debugging shows it would do with only 8K+3
137-
* (standard buffer for Java BufferedInputStream plus 3 bytes for largest
138-
* UTF BOM)
137+
* (standard buffer for Java BufferedInputStream plus 3 bytes for largest UTF BOM).
139138
*/
140139
private static final int MARK_READ_LIMIT = 1024 * 16;
141140

@@ -181,7 +180,7 @@ public class AnalyzerGuru {
181180
private static int customizationHashCode;
182181

183182
/**
184-
* Descending string length comparator for magics
183+
* Descending string length comparator for magics.
185184
*/
186185
private static final Comparator<String> descStrlenComparator =
187186
new Comparator<String>() {
@@ -230,14 +229,14 @@ public class AnalyzerGuru {
230229

231230
/**
232231
* Maps from {@link FileAnalyzer#getFileTypeName()} to
233-
* {@link FileAnalyzerFactory}
232+
* {@link FileAnalyzerFactory}.
234233
*/
235234
private static final Map<String, AnalyzerFactory> FILETYPE_FACTORIES =
236235
new HashMap<>();
237236

238237
/**
239238
* Maps from {@link FileAnalyzer#getFileTypeName()} to
240-
* {@link FileAnalyzer#getVersionNo()}
239+
* {@link FileAnalyzer#getVersionNo()}.
241240
*/
242241
private static final Map<String, Long> ANALYZER_VERSIONS = new HashMap<>();
243242

@@ -340,7 +339,7 @@ public static long getVersionNo() {
340339
final int ver32 = 20190211_00; // Edit comment above too!
341340
long ver = ver32;
342341
if (customizationHashCode != 0) {
343-
ver |= (long)customizationHashCode << 32;
342+
ver |= (long) customizationHashCode << 32;
344343
}
345344
return ver;
346345
}
@@ -611,7 +610,7 @@ public static String getContentType(InputStream in, String file) throws IOExcept
611610
}
612611

613612
/**
614-
* Write a browse-able version of the file
613+
* Write a browse-able version of the file.
615614
*
616615
* @param factory The analyzer factory for this file type
617616
* @param in The input stream containing the data
@@ -674,7 +673,7 @@ public static void writeDumpedXref(String contextPath,
674673
}
675674

676675
/**
677-
* Get the genre of a file
676+
* Get the genre of a file.
678677
*
679678
* @param file The file to inspect
680679
* @return The genre suitable to decide how to display the file
@@ -684,7 +683,7 @@ public static AbstractAnalyzer.Genre getGenre(String file) {
684683
}
685684

686685
/**
687-
* Get the genre of a bulk of data
686+
* Get the genre of a bulk of data.
688687
*
689688
* @param in A stream containing the data
690689
* @return The genre suitable to decide how to display the file
@@ -695,7 +694,7 @@ public static AbstractAnalyzer.Genre getGenre(InputStream in) throws IOException
695694
}
696695

697696
/**
698-
* Get the genre for a named class (this is most likely an analyzer)
697+
* Get the genre for a named class (this is most likely an analyzer).
699698
*
700699
* @param factory the analyzer factory to get the genre for
701700
* @return The genre of this class (null if not found)
@@ -767,9 +766,9 @@ public static Class<?> getFactoryClass(String simpleName) {
767766
// Build analysis package name list first time only
768767
if (analysisPkgNames.isEmpty()) {
769768
Package[] p = Package.getPackages();
770-
for(Package pp : p){
769+
for (Package pp : p) {
771770
String pname = pp.getName();
772-
if (pname.indexOf(".analysis.") != -1) {
771+
if (pname.contains(".analysis.")) {
773772
analysisPkgNames.add(pname);
774773
}
775774
}
@@ -781,11 +780,11 @@ public static Class<?> getFactoryClass(String simpleName) {
781780
// all language parsers:
782781
// <language>Analyzer, <language>AnalyzerFactory
783782

784-
if (simpleName.indexOf("Analyzer") == -1) {
783+
if (!simpleName.contains("Analyzer")) {
785784
simpleName += "Analyzer";
786785
}
787786

788-
if (simpleName.indexOf("Factory") == -1) {
787+
if (!simpleName.contains("Factory")) {
789788
simpleName += "Factory";
790789
}
791790

@@ -906,7 +905,7 @@ public static AnalyzerFactory find(String file) {
906905
}
907906

908907
/**
909-
* Finds a suitable analyzer class for the data in this stream
908+
* Finds a suitable analyzer class for the data in this stream.
910909
*
911910
* @param in The stream containing the data to analyze
912911
* @return the analyzer factory to use
@@ -919,7 +918,7 @@ public static AnalyzerFactory find(InputStream in) throws IOException {
919918

920919
/**
921920
* Finds a suitable analyzer class for the data in this stream
922-
* corresponding to a file of the specified name
921+
* corresponding to a file of the specified name.
923922
*
924923
* @param in The stream containing the data to analyze
925924
* @param file The file name to get the analyzer for
@@ -1101,7 +1100,7 @@ private static String readOpening(InputStream in, byte[] sig)
11011100
if (++nRead > OPENING_MAX_CHARS) {
11021101
break;
11031102
}
1104-
char c = (char)r;
1103+
char c = (char) r;
11051104
boolean isWhitespace = Character.isWhitespace(c);
11061105
if (!sawNonWhitespace) {
11071106
if (isWhitespace) {

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/AnalyzerGuruHelp.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
* Represents a utility class to show the user details of {@link AnalyzerGuru}.
3434
*/
3535
public class AnalyzerGuruHelp {
36+
37+
private AnalyzerGuruHelp() {
38+
}
39+
3640
/**
3741
* Gets a reportable hunk of text that details
3842
* {@link AnalyzerGuru#getPrefixesMap()},

0 commit comments

Comments
 (0)