Skip to content

Commit d6df19e

Browse files
ahornacevladak
authored andcommitted
Add MethodName CheckStyle check
1 parent 56b05e2 commit d6df19e

File tree

31 files changed

+386
-412
lines changed

31 files changed

+386
-412
lines changed

dev/checkstyle/style.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<module name="AvoidStarImport"/>
3030
<module name="RedundantImport"/>
3131
<module name="UnusedImports"/>
32+
<module name="MethodName"/>
3233
<module name="MethodLength">
3334
<property name="max" value="200"/>
3435
</module>

dev/checkstyle/suppressions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ Portions Copyright (c) 2018-2020, Chris Fraire <[email protected]>.
6161
<suppress checks="WhitespaceAfter" files="CustomSloppyPhraseScorer\.java|CustomPhraseQuery\.java" />
6262

6363
<suppress checks="AnonInnerLength" files="DummyHttpServletRequestLdap\.java|DummyHttpServletRequestUser\.java" />
64+
65+
<suppress checks="MethodName" files="org[\\/]opengrok[\\/]indexer[\\/]analysis" />
6466
</suppressions>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2011, Jens Elkner.
2323
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
2424
*/
@@ -286,7 +286,7 @@ public void linkageMatched(LinkageMatchedEvent evt) {
286286
case LABEL:
287287
// Only PowerShell seems to be using this.
288288
out.write("<a class=\"xlbl\" name=\"");
289-
Util.URIEncode(lstr, out);
289+
Util.uriEncode(lstr, out);
290290
out.write("\">");
291291
Util.htmlize(str, out, PRE);
292292
out.write("</a>");

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,8 @@ public static Scope maybeNewScope(boolean scopesEnabled,
170170
List<Tag> tags = defs.getTags(line);
171171
if (tags != null) {
172172
for (Tag tag : tags) {
173-
if (tag.type.startsWith("function") ||
174-
tag.type.startsWith("method")) {
175-
Scope scope = new Scope(tag.line, tag.line,
176-
tag.symbol, tag.namespace, tag.signature);
177-
return scope;
173+
if (tag.type.startsWith("function") || tag.type.startsWith("method")) {
174+
return new Scope(tag.line, tag.line, tag.symbol, tag.namespace, tag.signature);
178175
}
179176
}
180177
}
@@ -316,7 +313,7 @@ public static void writeSameFileLinkSymbol(Writer out, String symbol)
316313
out.append("<a class=\"");
317314
out.append(style_class);
318315
out.append(" intelliWindow-symbol\" href=\"#");
319-
Util.URIEncode(symbol, out);
316+
Util.uriEncode(symbol, out);
320317
out.append("\"");
321318
out.append(" data-definition-place=\"defined-in-file\"");
322319
out.append(">");

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/executables/JavaClassAnalyzer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2018, 2020, Chris Fraire <[email protected]>.
2323
* Portions Copyright (c) 2020, Lubos Kosco <[email protected]>.
2424
*/
@@ -173,14 +173,14 @@ void analyze(Document doc, InputStream in, Writer xrefOut,
173173
protected String linkPath(String path) {
174174
rstring.setLength(0);
175175
return rstring.append(AHREF).append(urlPrefix).append(QueryParameters.PATH_SEARCH_PARAM_EQ)
176-
.append(Util.URIEncodePath(path)).append(AHREFT_END)
176+
.append(Util.uriEncodePath(path)).append(AHREFT_END)
177177
.append(Util.htmlize(path)).append(AHREFEND).toString();
178178
}
179179

180180
protected String linkDef(String def) {
181181
rstring.setLength(0);
182182
return rstring.append(AHREF).append(urlPrefix).append(QueryParameters.DEFS_SEARCH_PARAM_EQ)
183-
.append(Util.URIEncode(def)).append(AHREFT_END)
183+
.append(Util.uriEncode(def)).append(AHREFT_END)
184184
.append(Util.htmlize(def)).append(AHREFEND).toString();
185185
}
186186

@@ -195,7 +195,7 @@ protected String tagDef(String def) {
195195
rstring.setLength(0);
196196
return rstring.append(ADHREF).append(Util.formQuoteEscape(name))
197197
.append(AIHREF).append(urlPrefix).append(QueryParameters.DEFS_SEARCH_PARAM_EQ)
198-
.append(Util.URIEncode(def)).append(AHREFT_END)
198+
.append(Util.uriEncode(def)).append(AHREFT_END)
199199
.append(Util.htmlize(def)).append(AHREFEND).toString();
200200
}
201201

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/ConfigMerge.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opengrok.indexer.configuration;
2424

@@ -65,7 +65,7 @@ public static void merge(Configuration cfgBase, Configuration cfgNew) throws Exc
6565
Modifier.isFinal(modifiers)) {
6666
continue;
6767
}
68-
PropertyDescriptor desc = null;
68+
PropertyDescriptor desc;
6969
try {
7070
desc = new PropertyDescriptor(fieldName, Configuration.class);
7171
} catch (IntrospectionException ex) {
@@ -108,31 +108,30 @@ public static void main(String[] argv) {
108108
getopt.parse();
109109
} catch (ParseException ex) {
110110
System.err.println(NAME + ": " + ex.getMessage());
111-
b_usage(System.err);
111+
bUsage(System.err);
112112
System.exit(1);
113113
}
114114

115115
int cmd;
116-
File f;
117116
getopt.reset();
118117
while ((cmd = getopt.getOpt()) != -1) {
119118
switch (cmd) {
120119
case '?':
121120
case 'h':
122-
a_usage(System.out);
121+
aUsage(System.out);
123122
System.exit(0);
124123
break;
125124
default:
126125
System.err.println("Internal Error - Not implemented option: " + (char) cmd);
127-
b_usage(System.err);
126+
bUsage(System.err);
128127
System.exit(1);
129128
break;
130129
}
131130
}
132131

133132
int optind = getopt.getOptind();
134133
if (optind < 0 || argv.length - optind != 2) {
135-
a_usage(System.err);
134+
aUsage(System.err);
136135
System.exit(1);
137136
}
138137

@@ -164,7 +163,7 @@ public static void main(String[] argv) {
164163
cfgNew.encodeObject(os);
165164
}
166165

167-
private static void a_usage(PrintStream out) {
166+
private static void aUsage(PrintStream out) {
168167
out.println("Usage:");
169168
out.println(NAME + " [-h] <config_file_base> <config_file_new>");
170169
out.println();
@@ -175,7 +174,7 @@ private static void a_usage(PrintStream out) {
175174
out.println();
176175
}
177176

178-
private static void b_usage(PrintStream out) {
177+
private static void bUsage(PrintStream out) {
179178
out.println("Maybe try to run " + NAME + " -h");
180179
}
181180
}

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private void markProjectIndexed(Project project) {
383383
.path("api")
384384
.path("v1")
385385
.path("projects")
386-
.path(Util.URIEncode(project.getName()))
386+
.path(Util.uriEncode(project.getName()))
387387
.path("indexed")
388388
.request()
389389
.headers(getWebAppHeaders())

opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
163163
throws HistoryException, IOException, ClassNotFoundException {
164164
Project p;
165165
String contextPath = sh.getContextPath();
166-
String ctxE = Util.URIEncodePath(contextPath);
166+
String ctxE = Util.uriEncodePath(contextPath);
167167
String xrefPrefix = contextPath + Prefix.XREF_P;
168168
String morePrefix = contextPath + Prefix.MORE_P;
169169
String xrefPrefixE = ctxE + Prefix.XREF_P;
@@ -178,7 +178,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
178178
String parent = entry.getKey();
179179
out.write("<tr class=\"dir\"><td colspan=\"3\"><a href=\"");
180180
out.write(xrefPrefixE);
181-
out.write(Util.URIEncodePath(parent));
181+
out.write(Util.uriEncodePath(parent));
182182
out.write("/\">");
183183
out.write(htmlize(parent));
184184
out.write("/</a>");
@@ -205,7 +205,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
205205
for (int docId : entry.getValue()) {
206206
Document doc = sh.getSearcher().doc(docId);
207207
String rpath = doc.get(QueryBuilder.PATH);
208-
String rpathE = Util.URIEncodePath(rpath);
208+
String rpathE = Util.uriEncodePath(rpath);
209209
if (evenRow) {
210210
out.write("<tr class=\"search-result-even-row\">");
211211
} else {

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,12 @@ public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
177177
AbstractAnalyzer anz = fac.getAnalyzer();
178178

179179
String path = doc.get(QueryBuilder.PATH);
180-
String pathE = Util.URIEncodePath(path);
181-
String urlPrefixE = urlPrefix == null ? "" : Util.URIEncodePath(
182-
urlPrefix);
183-
String moreURL = morePrefix == null ? null : Util.URIEncodePath(
184-
morePrefix) + pathE + "?" + queryAsURI;
185-
186-
ContextArgs args = new ContextArgs(env.getContextSurround(),
187-
env.getContextLimit());
188-
/**
180+
String pathE = Util.uriEncodePath(path);
181+
String urlPrefixE = urlPrefix == null ? "" : Util.uriEncodePath(urlPrefix);
182+
String moreURL = morePrefix == null ? null : Util.uriEncodePath(morePrefix) + pathE + "?" + queryAsURI;
183+
184+
ContextArgs args = new ContextArgs(env.getContextSurround(), env.getContextLimit());
185+
/*
189186
* Lucene adds to the following value in FieldHighlighter, so avoid
190187
* integer overflow by not using Integer.MAX_VALUE -- Short is good
191188
* enough.
@@ -238,8 +235,7 @@ private String buildQueryAsURI(Map<String, String> subqueries) {
238235
for (Map.Entry<String, String> entry : subqueries.entrySet()) {
239236
String field = entry.getKey();
240237
String queryText = entry.getValue();
241-
sb.append(field).append("=").append(Util.URIEncode(queryText))
242-
.append('&');
238+
sb.append(field).append("=").append(Util.uriEncode(queryText)).append('&');
243239
}
244240
sb.setLength(sb.length() - 1);
245241
return sb.toString();
@@ -277,9 +273,8 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
277273
}
278274
boolean anything = false;
279275
TreeMap<Integer, String[]> matchingTags = null;
280-
String urlPrefixE =
281-
(urlPrefix == null) ? "" : Util.URIEncodePath(urlPrefix);
282-
String pathE = Util.URIEncodePath(path);
276+
String urlPrefixE = (urlPrefix == null) ? "" : Util.uriEncodePath(urlPrefix);
277+
String pathE = Util.uriEncodePath(path);
283278
if (tags != null) {
284279
matchingTags = new TreeMap<>();
285280
try {
@@ -354,9 +349,8 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
354349
}
355350
}
356351
}
357-
/**
358-
* Just to get the matching tag send a null in
359-
*/
352+
353+
// Just to get the matching tag send a null in
360354
if (in == null) {
361355
return anything;
362356
}
@@ -433,9 +427,8 @@ public boolean getContext(Reader in, Writer out, String urlPrefix,
433427
}
434428
anything = matchedLines > 0;
435429
tokens.dumpRest();
436-
if (lim && (truncated || matchedLines == limit_max_lines) &&
437-
out != null) {
438-
out.write("<a href=\"" + Util.URIEncodePath(morePrefix) + pathE + "?" + queryAsURI + "\">[all...]</a>");
430+
if (lim && (truncated || matchedLines == limit_max_lines) && out != null) {
431+
out.write("<a href=\"" + Util.uriEncodePath(morePrefix) + pathE + "?" + queryAsURI + "\">[all...]</a>");
439432
}
440433
} catch (IOException e) {
441434
LOGGER.log(Level.WARNING, "Could not get context for " + path, e);

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/HistoryContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ protected static void writeMatch(Appendable out, String line,
237237
if (wcontext != null && nrev != null && !wcontext.isEmpty()) {
238238
out.append("<a href=\"");
239239
printHTML(out, wcontext + Prefix.DIFF_P +
240-
Util.URIEncodePath(path) +
241-
"?" + QueryParameters.REVISION_2_PARAM_EQ + Util.URIEncodePath(path) + "@" +
242-
rev + "&" + QueryParameters.REVISION_1_PARAM_EQ + Util.URIEncodePath(path) +
240+
Util.uriEncodePath(path) +
241+
"?" + QueryParameters.REVISION_2_PARAM_EQ + Util.uriEncodePath(path) + "@" +
242+
rev + "&" + QueryParameters.REVISION_1_PARAM_EQ + Util.uriEncodePath(path) +
243243
"@" + nrev + "\" title=\"diff to previous version\"", flatten);
244244
out.append(">diff</a> ");
245245
}

opengrok-indexer/src/main/java/org/opengrok/indexer/util/IOUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,29 +218,29 @@ public static Reader createBOMStrippedReader(InputStream stream, String defaultC
218218
* Byte-order markers.
219219
*/
220220
private static final Map<String, byte[]> BOMS = Map.of(
221-
StandardCharsets.UTF_8.name(), UTF_8_BOM(),
222-
StandardCharsets.UTF_16BE.name(), UTF_16BE_BOM(),
223-
StandardCharsets.UTF_16LE.name(), UTF_16LE_BOM()
221+
StandardCharsets.UTF_8.name(), utf8Bom(),
222+
StandardCharsets.UTF_16BE.name(), utf16BeBom(),
223+
StandardCharsets.UTF_16LE.name(), utf16LeBom()
224224
);
225225

226226
/**
227227
* Gets a new array containing the UTF-8 BOM.
228228
*/
229-
public static byte[] UTF_8_BOM() {
229+
public static byte[] utf8Bom() {
230230
return new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF};
231231
}
232232

233233
/**
234234
* Gets a new array containing the UTF-16BE BOM (Big-Endian).
235235
*/
236-
public static byte[] UTF_16BE_BOM() {
236+
public static byte[] utf16BeBom() {
237237
return new byte[]{(byte) 0xFE, (byte) 0xFF};
238238
}
239239

240240
/**
241241
* Gets a new array containing the UTF-16LE BOM (Little-Endian).
242242
*/
243-
public static byte[] UTF_16LE_BOM() {
243+
public static byte[] utf16LeBom() {
244244
return new byte[]{(byte) 0xFF, (byte) 0xFE};
245245
}
246246

opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ private void maybeRedirectToDefinition(int docID, TermQuery termQuery)
534534
Definitions tags = Definitions.deserialize(rawTags);
535535
String symbol = termQuery.getTerm().text();
536536
if (tags.occurrences(symbol) == 1) {
537-
String anchor = Util.URIEncode(symbol);
537+
String anchor = Util.uriEncode(symbol);
538538
redirect = contextPath + Prefix.XREF_P
539-
+ Util.URIEncodePath(doc.get(QueryBuilder.PATH))
539+
+ Util.uriEncodePath(doc.get(QueryBuilder.PATH))
540540
+ '?' + QueryParameters.FRAGMENT_IDENTIFIER_PARAM_EQ + anchor
541541
+ '#' + anchor;
542542
}
@@ -580,15 +580,15 @@ private void maybeRedirectToMatchOffset(int docID, List<String> contextFields)
580580
}
581581
if (offset >= 0) {
582582
redirect = contextPath + Prefix.XREF_P
583-
+ Util.URIEncodePath(doc.get(QueryBuilder.PATH))
583+
+ Util.uriEncodePath(doc.get(QueryBuilder.PATH))
584584
+ '?' + QueryParameters.MATCH_OFFSET_PARAM_EQ + offset;
585585
}
586586
}
587587
}
588588

589589
private void redirectToFile(int docID) throws IOException {
590590
Document doc = searcher.doc(docID);
591-
redirect = contextPath + Prefix.XREF_P + Util.URIEncodePath(doc.get(QueryBuilder.PATH));
591+
redirect = contextPath + Prefix.XREF_P + Util.uriEncodePath(doc.get(QueryBuilder.PATH));
592592
}
593593

594594
private void getSuggestion(Term term, IndexReader ir,

0 commit comments

Comments
 (0)