Skip to content

Commit 786b9f4

Browse files
idodeclareVladimir Kotal
authored andcommitted
Fix up some code warnings
1 parent f512400 commit 786b9f4

File tree

1 file changed

+28
-37
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/index

1 file changed

+28
-37
lines changed

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

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public static void main(String[] argv) {
250250
IndexVersion.check(subFilesList);
251251
} catch (IndexVersionException e) {
252252
System.err.printf("Index version check failed: %s\n", e);
253-
System.err.printf("You might want to remove " +
253+
System.err.print("You might want to remove " +
254254
(subFilesList.size() > 0 ?
255255
"data for projects " + String.join(",", subFilesList) : "all data") +
256256
" under the DATA_ROOT and to reindex\n");
@@ -407,17 +407,16 @@ public static String[] parseOptions(String[] argv) throws ParseException {
407407
boolean preHelp = Arrays.stream(argv).anyMatch(s -> HELP_OPT_1.equals(s) ||
408408
HELP_OPT_2.equals(s) || HELP_OPT_3.equals(s));
409409

410-
OptionParser configure = OptionParser.scan(parser -> {
411-
parser.on("-R configPath").Do(cfgFile -> {
412-
try {
413-
if (!preHelp) {
414-
cfg = Configuration.read(new File((String) cfgFile));
415-
}
416-
} catch (IOException e) {
417-
die(e.getMessage());
410+
OptionParser configure = OptionParser.scan(parser ->
411+
parser.on("-R configPath").Do(cfgFile -> {
412+
try {
413+
if (!preHelp) {
414+
cfg = Configuration.read(new File((String) cfgFile));
418415
}
419-
});
420-
});
416+
} catch (IOException e) {
417+
die(e.getMessage());
418+
}
419+
}));
421420

422421
searchPaths.clear();
423422

@@ -450,9 +449,9 @@ public static String[] parseOptions(String[] argv) throws ParseException {
450449
"/(\\.\\w+|\\w+\\.):(-|[a-zA-Z_0-9.]+)/",
451450
"Associates files with the specified prefix or extension (case-",
452451
"insensitive) to be analyzed with the given analyzer, where 'analyzer'",
453-
"may be specified using a simple class name (case-sensitive e.g.",
454-
"RubyAnalyzer) or language name (case-sensitive e.g. C) prefix. Option",
455-
"may be repeated.",
452+
"may be specified using a class name (case-sensitive e.g. RubyAnalyzer)",
453+
"or analyzer language name (case-sensitive e.g. C). Option may be",
454+
"repeated.",
456455
" Ex: -A .foo:CAnalyzer",
457456
" will use the C analyzer for all files ending with .FOO",
458457
" Ex: -A bar.:Perl",
@@ -469,9 +468,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
469468
);
470469

471470
parser.on("-c", "--ctags", "=/path/to/ctags",
472-
"Path to Universal Ctags. Default is ctags in PATH.").Do(ctagsPath ->
473-
cfg.setCtags((String) ctagsPath)
474-
);
471+
"Path to Universal Ctags. Default is ctags in environment PATH.").Do(
472+
v -> cfg.setCtags((String) v));
475473

476474
parser.on("--canonicalRoot", "=/path/",
477475
"Allow symlinks to canonical targets starting with the specified root",
@@ -487,9 +485,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
487485
});
488486

489487
parser.on("--checkIndexVersion",
490-
"Check if current Lucene version matches index version.").Do(v -> {
491-
checkIndexVersion = true;
492-
});
488+
"Check if current Lucene version matches index version.").Do(v ->
489+
checkIndexVersion = true);
493490

494491
parser.on("-d", "--dataRoot", "=/path/to/data/root",
495492
"The directory where OpenGrok stores the generated data.").
@@ -511,9 +508,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
511508

512509
parser.on("--depth", "=number", Integer.class,
513510
"Scanning depth for repositories in directory structure relative to",
514-
"source root. Default is " + Configuration.defaultScanningDepth + ".").Do(depth -> {
515-
cfg.setScanningDepth((Integer) depth);
516-
});
511+
"source root. Default is " + Configuration.defaultScanningDepth + ".").Do(depth ->
512+
cfg.setScanningDepth((Integer) depth));
517513

518514
parser.on("--disableRepository", "=type_name",
519515
"Disables operation of an OpenGrok-supported repository. See also",
@@ -537,13 +533,10 @@ public static String[] parseOptions(String[] argv) throws ParseException {
537533
"be slightly slow.").Do(v -> cfg.setGenerateHtml(false));
538534

539535
parser.on("-G", "--assignTags",
540-
"Assign commit tags to all entries in history for all repositories.").Do(v -> {
541-
cfg.setTagsEnabled(true);
542-
});
536+
"Assign commit tags to all entries in history for all repositories.").Do(v ->
537+
cfg.setTagsEnabled(true));
543538

544-
parser.on("-H", "--history", "Enable history.").Do(v -> {
545-
cfg.setHistoryEnabled(true);
546-
});
539+
parser.on("-H", "--history", "Enable history.").Do(v -> cfg.setHistoryEnabled(true));
547540

548541
parser.on("-I", "--include", "=pattern",
549542
"Only files matching this pattern will be examined. Pattern supports",
@@ -571,9 +564,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
571564
});
572565

573566
parser.on("--leadingWildCards", "=on|off", ON_OFF, Boolean.class,
574-
"Allow or disallow leading wildcards in a search. Default is on.").Do(v -> {
575-
cfg.setAllowLeadingWildcard((Boolean) v);
576-
});
567+
"Allow or disallow leading wildcards in a search. Default is on.").Do(v ->
568+
cfg.setAllowLeadingWildcard((Boolean) v));
577569

578570
parser.on("-m", "--memory", "=number", Double.class,
579571
"Amount of memory (MB) that may be used for buffering added documents and",
@@ -661,9 +653,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
661653
cfg.setQuickContextScan((Boolean) v));
662654

663655
parser.on("-q", "--quiet",
664-
"Run as quietly as possible. Sets logging level to WARNING.").Do(v -> {
665-
LoggerUtil.setBaseConsoleLogLevel(Level.WARNING);
666-
});
656+
"Run as quietly as possible. Sets logging level to WARNING.").Do(v ->
657+
LoggerUtil.setBaseConsoleLogLevel(Level.WARNING));
667658

668659
parser.on("-R /path/to/configuration",
669660
"Read configuration from the specified file.").Do(v -> {
@@ -821,7 +812,7 @@ private static void checkConfiguration() {
821812
}
822813

823814
if (repositories.size() > 0 && !cfg.isHistoryEnabled()) {
824-
die("Repositories were specified; however history is off");
815+
die("Repositories were specified; history is off however");
825816
}
826817
}
827818

@@ -988,7 +979,7 @@ public void prepareIndexer(RuntimeEnvironment env,
988979
// Even if history is disabled globally, it can be enabled for some repositories.
989980
if (repositories != null && !repositories.isEmpty()) {
990981
LOGGER.log(Level.INFO, "Generating history cache for repositories: " +
991-
repositories.stream().collect(Collectors.joining(",")));
982+
String.join(",", repositories));
992983
HistoryGuru.getInstance().createCache(repositories);
993984
LOGGER.info("Done...");
994985
} else {

0 commit comments

Comments
 (0)