From e348042f363215ceb40db283a450fd352bc5e3d9 Mon Sep 17 00:00:00 2001 From: Gino Augustine Date: Tue, 14 Nov 2023 08:40:19 +0530 Subject: [PATCH] Upgrade checkstyle and add new rules Signed-off-by: Gino Augustine --- dev/checkstyle/style.xml | 7 +++ .../indexer/analysis/PathTokenizer.java | 14 ++--- .../analysis/uue/UuencodeAnalyzerFactory.java | 10 ++-- .../authorization/AuthorizationEntity.java | 23 ++++---- .../authorization/AuthorizationPlugin.java | 28 +++++----- .../configuration/CommandTimeoutType.java | 5 ++ .../indexer/configuration/Configuration.java | 9 ++-- .../indexer/history/AnnotationCache.java | 3 ++ .../org/opengrok/indexer/history/Cache.java | 3 ++ .../opengrok/indexer/history/HistoryGuru.java | 2 +- .../indexer/history/RazorHistoryParser.java | 2 +- .../opengrok/indexer/history/Repository.java | 2 +- .../indexer/history/SCCSHistoryParser.java | 2 +- .../indexer/index/IndexAnalysisSettings.java | 6 +-- .../opengrok/indexer/index/IndexDatabase.java | 4 +- .../opengrok/indexer/search/QueryBuilder.java | 10 ++-- .../opengrok/indexer/search/SearchEngine.java | 8 +-- .../search/context/ContextFormatter.java | 8 +-- .../search/context/OGKUnifiedHighlighter.java | 53 ++++++++++--------- .../search/context/PhraseHighlight.java | 3 +- .../org/opengrok/indexer/util/DTOElement.java | 4 ++ .../opengrok/indexer/util/OptionParser.java | 15 +++--- .../org/opengrok/indexer/util/Statistics.java | 4 +- .../indexer/web/messages/JSONable.java | 3 ++ .../indexer/web/messages/Message.java | 3 ++ .../AuthorizationEntityTest.java | 28 +++++----- .../indexer/authorization/TestPlugin.java | 4 ++ .../condition/EnabledForRepository.java | 3 ++ .../condition/RepositoryInstalled.java | 6 +++ .../search/context/ContextFormatterTest.java | 6 +-- .../indexer/web/messages/JSONUtils.java | 3 ++ .../java/org/opengrok/web/PageConfig.java | 2 +- .../java/org/opengrok/web/ProjectHelper.java | 4 +- .../web/api/v1/filter/PathAuthorized.java | 3 ++ .../suggester/provider/filter/Authorized.java | 3 ++ .../suggester/provider/filter/Suggester.java | 4 ++ .../provider/service/SuggesterService.java | 3 ++ .../web/ProjectHelperExtendedTest.java | 14 ++--- .../auth/plugin/LdapFilterPlugin.java | 4 +- .../opengrok/auth/plugin/LdapUserPlugin.java | 4 +- .../opengrok/auth/plugin/util/Timestamp.java | 2 +- pom.xml | 4 +- .../suggest/query/SuggesterRangeQuery.java | 3 ++ 43 files changed, 193 insertions(+), 138 deletions(-) diff --git a/dev/checkstyle/style.xml b/dev/checkstyle/style.xml index 5b13557e767..d1ca4b6aafd 100644 --- a/dev/checkstyle/style.xml +++ b/dev/checkstyle/style.xml @@ -25,7 +25,14 @@ + + + + + diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java index 24bd97f2b7c..d1cd58ea06d 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java @@ -92,13 +92,13 @@ public final boolean incrementToken() throws IOException { if (i >= buf.length) { buf = Arrays.copyOf(buf, buf.length * 2); } - /** - * "In general, String.toLowerCase(Locale) should be used to map - * characters to lowercase. String case mapping methods have several - * benefits over Character case mapping methods. String case mapping - * methods can perform locale-sensitive mappings, context-sensitive - * mappings, and 1:M character mappings, whereas the Character case - * mapping methods cannot." See below. + /* + "In general, String.toLowerCase(Locale) should be used to map + characters to lowercase. String case mapping methods have several + benefits over Character case mapping methods. String case mapping + methods can perform locale-sensitive mappings, context-sensitive + mappings, and 1:M character mappings, whereas the Character case + mapping methods cannot." See below. */ buf[i++] = (char) c; c = input.read(); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/uue/UuencodeAnalyzerFactory.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/uue/UuencodeAnalyzerFactory.java index fbe942950e4..e452392ef91 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/uue/UuencodeAnalyzerFactory.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/uue/UuencodeAnalyzerFactory.java @@ -35,11 +35,11 @@ public class UuencodeAnalyzerFactory extends FileAnalyzerFactory { private static final String NAME = "UUEncoded"; private static final String[] SUFFIXES = { - /** - * XXX: - * FreeBSD and DragonFly .fnt files are uuencoded; - * Minix3 .fnt files are binary. -- 2013-04 cnst - */ + /* + XXX: + FreeBSD and DragonFly .fnt files are uuencoded; + Minix3 .fnt files are binary. -- 2013-04 cnst + */ "UU", "UUE", /*"FNT",*/ "BASE64" }; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java index d00e3a6eb09..086bb540301 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java @@ -420,13 +420,13 @@ protected void processTargetGroupsAndProjects() { Set groups = new TreeSet<>(); for (String x : forGroups()) { - /** - * Full group discovery takes place here. All projects/repositories - * in the group are added into "forProjects" and all subgroups - * (including projects/repositories) and parent groups (excluding - * the projects/repositories) are added into "forGroups". - * - * If the group does not exist then a warning is issued. + /* + Full group discovery takes place here. All projects/repositories + in the group are added into "forProjects" and all subgroups + (including projects/repositories) and parent groups (excluding + the projects/repositories) are added into "forGroups". + + If the group does not exist then a warning is issued. */ Group g; if ((g = Group.getByName(x)) != null) { @@ -442,9 +442,9 @@ protected void processTargetGroupsAndProjects() { setForGroups(groups); forProjects().removeIf(t -> { - /** - * Check the existence of the projects and issue a warning if there - * is no such project. + /* + Check the existence of the projects and issue a warning if there + is no such project. */ if ( Project.getByName(t) == null) { LOGGER.log(Level.WARNING, "Configured project \"{0}\" in forProjects" @@ -474,8 +474,7 @@ public synchronized void setWorking() { /** * Check if this plugin has failed during loading or is missing. - * - * This method has the same effect as !{@link isWorking()}. + * This method has the same effect as !{@link #isWorking()}. * * @return true if failed, true otherwise * @see #isWorking() diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationPlugin.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationPlugin.java index b2eb339c221..8c9217f0ad0 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationPlugin.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationPlugin.java @@ -171,12 +171,12 @@ public synchronized void unload() { public boolean isAllowed(Nameable entity, AuthorizationEntity.PluginDecisionPredicate pluginPredicate, AuthorizationEntity.PluginSkippingPredicate skippingPredicate) { - /** - * We don't check the skippingPredicate here as this instance is - * always a part of some stack (may be the default stack) and the - * stack checks the skipping predicate before invoking this method. - * - * @see AuthorizationStack#processStack + /* + We don't check the skippingPredicate here as this instance is + always a part of some stack (may be the default stack) and the + stack checks the skipping predicate before invoking this method. + + @see AuthorizationStack#processStack */ if (isFailed()) { @@ -205,14 +205,14 @@ public boolean setPlugin(IAuthorizationPlugin plugin) { unload(); } try { - /** - * The exception should not happen here as we already have an - * instance of IAuthorizationPlugin. But it is required by the - * compiler. - * - * NOTE: If we were to add a throws clause here we would interrupt - * the whole stack walk through and prevent the other authorization - * entities to work properly. + /* + The exception should not happen here as we already have an + instance of IAuthorizationPlugin. But it is required by the + compiler. + + NOTE: If we were to add a throws clause here we would interrupt + the whole stack walk through and prevent the other authorization + entities to work properly. */ this.plugin = plugin.getClass().getDeclaredConstructor().newInstance(); return true; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/CommandTimeoutType.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/CommandTimeoutType.java index aa66908b30a..0976c3d4cf6 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/CommandTimeoutType.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/CommandTimeoutType.java @@ -22,6 +22,11 @@ */ package org.opengrok.indexer.configuration; +/** + * Command Time Out Type. + * Different time out config valid are present for each + * command type. + */ public enum CommandTimeoutType { INTERACTIVE, INDEXER, diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java index 8dc1b95d9b3..d9fed1c0ace 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java @@ -642,19 +642,18 @@ public Map getCmds() { /** * @return int the current message limit * @see org.opengrok.indexer.web.messages.MessagesContainer - * - * @return int the current message limit */ public int getMessageLimit() { return messageLimit; } /** - * @see org.opengrok.indexer.web.messages.MessagesContainer * * @param messageLimit the limit * @throws IllegalArgumentException when the limit is negative + * @see org.opengrok.indexer.web.messages.MessagesContainer */ + public void setMessageLimit(int messageLimit) throws IllegalArgumentException { if (messageLimit < 0) { throw new IllegalArgumentException( @@ -940,12 +939,10 @@ public String getDataRoot() { /** * Sets data root. - * * This method also sets the pluginDirectory if it is not already set. * - * @see #setPluginDirectory(java.lang.String) - * * @param dataRoot data root path + * @see #setPluginDirectory(java.lang.String) */ public void setDataRoot(String dataRoot) { if (dataRoot != null && getPluginDirectory() == null) { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationCache.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationCache.java index 5542b10b48a..fde8033a443 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationCache.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationCache.java @@ -26,6 +26,9 @@ import java.io.File; +/** + * Annotation Cache Related Operations. + */ public interface AnnotationCache extends Cache { /** * Retrieve annotation from cache. diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Cache.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Cache.java index 58898ab4951..31397368c05 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Cache.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Cache.java @@ -29,6 +29,9 @@ import java.util.List; import java.util.logging.Logger; +/** + * Cache interface for common cache related operations. + */ public interface Cache { Logger LOGGER = LoggerFactory.getLogger(Cache.class); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java index 1f0c6f5830b..cd79fb3417d 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java @@ -783,7 +783,6 @@ public boolean fillLastHistoryEntries(File directory, List entri /** * Recursively search for repositories with a depth limit, add those found to the internally used map. - * @see #putRepository(Repository) * * @param files list of directories to check if they contain a repository * @param allowedNesting number of levels of nested repos to allow @@ -791,6 +790,7 @@ public boolean fillLastHistoryEntries(File directory, List entri * @param isNested a value indicating if a parent {@link Repository} was already found above the {@code files} * @param progress {@link org.opengrok.indexer.util.Progress} instance * @return collection of added repositories + * @see #putRepository(Repository) */ private Collection addRepositories(File[] files, int allowedNesting, int depth, boolean isNested, Progress progress) { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RazorHistoryParser.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RazorHistoryParser.java index 83209aa6848..b2a02955389 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RazorHistoryParser.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RazorHistoryParser.java @@ -39,7 +39,7 @@ /** * A History Parser for Razor. * - * @author Peter Bray + * @author Peter Bray <Peter.Darren.Bray@gmail.com> */ class RazorHistoryParser { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java index 96e691315c3..9dedd276ee3 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java @@ -293,8 +293,8 @@ TreeSet getTagList() { * tags to changesets which actually exist in the history of given file. * Must be implemented repository-specific. * - * @see #getTagList * @param hist History object we want to assign tags to. + * @see #getTagList */ void assignTagsInHistory(History hist) { if (hist == null) { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SCCSHistoryParser.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SCCSHistoryParser.java index 0fc55d944d2..5f15f217b8d 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SCCSHistoryParser.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SCCSHistoryParser.java @@ -109,8 +109,8 @@ private History parseFile(File file) throws IOException, ParseException { /** * Read a single line of delta record into the {@link #sccsRecord} member. * - * @throws java.io.IOException on I/O error * @return boolean indicating whether there is another record. + * @throws java.io.IOException on I/O error */ private boolean next() throws java.io.IOException { sep = true; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java index 7b62582e0e8..e180f4bae7a 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java @@ -180,9 +180,9 @@ private void readObject(ObjectInputStream in) throws ClassNotFoundException, long vlong = in.readLong(); analyzerGuruVersion = hasValue ? vlong : null; - /** - * De-serialization circumvents normal construction, so the following - * field could be null. + /* + De-serialization circumvents normal construction, so the following + field could be null. */ if (analyzersVersions == null) { analyzersVersions = new HashMap<>(); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java index 781bca9c4f0..c74e9ed3ea1 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java @@ -1905,8 +1905,8 @@ public void addIndexChangedListener(IndexChangedListener listener) { * Get all files in some of the index databases. * * @param subFiles Subdirectories of various projects or null or an empty list to get everything - * @throws IOException if an error occurs * @return set of files in the index databases specified by the subFiles parameter + * @throws IOException if an error occurs */ public static Set getAllFiles(List subFiles) throws IOException { Set files = new HashSet<>(); @@ -1940,8 +1940,8 @@ public static Set getAllFiles(List subFiles) throws IOException /** * Get all files in this index database. * - * @throws IOException If an IO error occurs while reading from the database * @return set of files in this index database + * @throws IOException If an IO error occurs while reading from the database */ public Set getFiles() throws IOException { IndexReader ireader = null; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java index daca57465c8..cfaa0769697 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java @@ -310,11 +310,11 @@ public Map getQueries() { */ public List getContextFields() { List fields = new ArrayList<>(queries.size()); - /** - * setFreetext() allows query fragments that specify a field name with - * a colon (e.g., "defs:ensure_cache" in the "Full Search" box), so the - * context fields (i.e., the result of this method) are not just the - * keys of `queries' but need a full parsing to be determined. + /* + setFreetext() allows query fragments that specify a field name with + a colon (e.g., "defs:ensure_cache" in the "Full Search" box), so the + context fields (i.e., the result of this method) are not just the + keys of `queries' but need a full parsing to be determined. */ Query query; try { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java index 9c3e1604cb8..e12ad247142 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java @@ -477,10 +477,10 @@ public void results(int start, int end, List ret) { getDefinition() != null, ret, scopes); } else if (AbstractAnalyzer.Genre.XREFABLE == genre && data != null && summarizer != null) { int l; - /** - * For backward compatibility, read the - * OpenGrok-produced document using the system - * default charset. + /* + For backward compatibility, read the + OpenGrok-produced document using the system + default charset. */ try (Reader r = RuntimeEnvironment.getInstance().isCompressXref() ? new HTMLStripCharFilter(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream( diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/ContextFormatter.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/ContextFormatter.java index e646d2ceb52..b6c5d05c135 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/ContextFormatter.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/ContextFormatter.java @@ -271,10 +271,10 @@ public Object format(Passage[] passages, String originalText) { finishLine(bld, lhi.getLineno(), marks); // Regardless of true EOL, write a
. bld.append(HtmlConsts.BR); - /** - * Appending a LF here would hurt the more.jsp view, while - * search.jsp (where getContext() does it) is indifferent -- so - * skip it. + /* + Appending a LF here would hurt the more.jsp view, while + search.jsp (where getContext() does it) is indifferent -- so + skip it. */ res.put(lhi.getLineno(), bld.toString()); bld.setLength(0); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java index bf4a5f3d8ea..92a7f897fcc 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java @@ -71,9 +71,10 @@ public class OGKUnifiedHighlighter extends UnifiedHighlighter { * {@link UnifiedHighlighter#UnifiedHighlighter(UnifiedHighlighter.Builder)} * for the specified {@code indexSearcher} and {@code indexAnalyzer}, and * stores the {@code env} for later use. + * * @param env a required instance - * @throws IllegalArgumentException if any argument is null * @param uhBuilder a required instance + * @throws IllegalArgumentException if any argument is null */ public OGKUnifiedHighlighter(RuntimeEnvironment env, UnifiedHighlighter.Builder uhBuilder) { @@ -122,11 +123,11 @@ public void setTabSize(int value) { */ public String highlightFieldsUnion(String[] fields, Query query, int docId, int lineLimit) throws IOException { - /** - * Setting fileTypeName has to happen before getFieldHighlighter() is - * called by highlightFieldsAsObjects() so that the result of - * getIndexAnalyzer() (if it is called due to requiring ANALYSIS) can be - * influenced by fileTypeName. + /* + Setting fileTypeName has to happen before getFieldHighlighter() is + called by highlightFieldsAsObjects() so that the result of + getIndexAnalyzer() (if it is called due to requiring ANALYSIS) can be + influenced by fileTypeName. */ Document doc = searcher.storedFields().document(docId); fileTypeName = doc == null ? null : doc.get(QueryBuilder.TYPE); @@ -152,9 +153,9 @@ public String highlightFieldsUnion(String[] fields, Query query, protected String highlightFieldsUnionWork(String[] fields, Query query, int docId, int lineLimit) throws IOException { int[] maxPassagesCopy = new int[fields.length]; - /** - * N.b. linelimit + 1 so that the ContextFormatter has an indication - * when to display the "more..." link. + /* + N.b. linelimit + 1 so that the ContextFormatter has an indication + when to display the "more..." link. */ Arrays.fill(maxPassagesCopy, lineLimit + 1); @@ -163,9 +164,9 @@ protected String highlightFieldsUnionWork(String[] fields, Query query, query, new int[]{docId}, maxPassagesCopy); for (Object[] flinesz : mappedRes.values()) { for (Object obj : flinesz) { - /** - * Empirical testing showed that the passage could be null if - * the original source text is not available to the highlighter. + /* + Empirical testing showed that the passage could be null if + the original source text is not available to the highlighter. */ if (obj != null) { if (!(obj instanceof FormattedLines)) { @@ -248,20 +249,20 @@ protected OffsetSource getOptimizedOffsetSource(UHComponents components) { OffsetSource res = super.getOptimizedOffsetSource(components); String field = components.getField(); if (res == OffsetSource.ANALYSIS) { - /** - * Testing showed that UnifiedHighlighter falls back to - * ANALYSIS in the presence of multi-term queries (MTQs) such as - * prefixes and wildcards even for fields that are analyzed with - * POSTINGS -- i.e. with DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS. - * This is despite UnifiedHighlighter seeming to indicate that - * postings should be sufficient in the comment for - * shouldHandleMultiTermQuery(String): "MTQ highlighting can be - * expensive, particularly when using offsets in postings." - * DEFS are stored with term vectors to avoid this problem, - * since re-analysis would not at all accord with ctags Definitions. - * For FULL and REFS, highlightFieldsUnion() arranges that - * getIndexAnalyzer() can return a TYPE-specific analyzer for use by - * getOffsetStrategy() -- if re-ANALYSIS is required. + /* + Testing showed that UnifiedHighlighter falls back to + ANALYSIS in the presence of multi-term queries (MTQs) such as + prefixes and wildcards even for fields that are analyzed with + POSTINGS -- i.e. with DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS. + This is despite UnifiedHighlighter seeming to indicate that + postings should be sufficient in the comment for + shouldHandleMultiTermQuery(String): "MTQ highlighting can be + expensive, particularly when using offsets in postings." + DEFS are stored with term vectors to avoid this problem, + since re-analysis would not at all accord with ctags Definitions. + For FULL and REFS, highlightFieldsUnion() arranges that + getIndexAnalyzer() can return a TYPE-specific analyzer for use by + getOffsetStrategy() -- if re-ANALYSIS is required. */ switch (field) { case QueryBuilder.FULL: diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PhraseHighlight.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PhraseHighlight.java index 164e28c717b..8276c9ce9a5 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PhraseHighlight.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PhraseHighlight.java @@ -79,8 +79,9 @@ public int getLineEnd() { /** * Determines if the specified {@code other} overlaps with this instance. - * @return {@code true} if the instances overlap + * * @param other object to compare to + * @return {@code true} if the instances overlap */ public boolean overlaps(PhraseHighlight other) { return (lineStart >= other.lineStart && lineStart <= other.lineEnd) || diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/DTOElement.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/DTOElement.java index a8cad89967f..a0d3dfb28bd 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/DTOElement.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/DTOElement.java @@ -27,6 +27,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Annotated fields will be present in generated DTO object. + * + */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface DTOElement { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/OptionParser.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/OptionParser.java index 6d361a52659..48c3caf8208 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/OptionParser.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/OptionParser.java @@ -39,30 +39,31 @@ /** * OptionParser is a class for command-line option analysis. - * + *

* Now that Java 8 has the crucial Lambda and Consumer interfaces, we can * implement a more powerful program option parsing mechanism, ala ruby * OptionParser style. - * + *

* Features + *

* o An option can have multiple short names (-x) and multiple long * names (--xyz). Thus, an option that displays a programs usage * may be available as -h, -?, --help, --usage, and --about. - * + *

* o An option may be specified as having no argument, an optional * argument, or a required argument. Arguments may be validated * against a regular expression pattern or a list of valid values. - * + *

* o The argument specification and the code to handle it are * written in the same place. The argument description may consist * of one or more lines to be used when displaying usage summary. - * + *

* o The option summary is produced without maintaining strings * in a separate setting. - * + *

* o Users are allowed to enter initial substrings for long option * names as long as there is no ambiguity. - * + *

* o Supports the ability to coerce command line arguments into objects. * This class readily supports Boolean (yes/no,true/false,on/off), * Float, Double, Integer, and String[] (strings separated by comma) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Statistics.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Statistics.java index a7360a6e9de..94bb28c1c66 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Statistics.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Statistics.java @@ -79,8 +79,8 @@ public boolean report(Logger logger, Level logLevel, String msg) { * @param logLevel log level * @param msg message string * @param meterName name of the meter - * @see Metrics#getRegistry() * @return whether logging was performed + * @see Metrics#getRegistry() */ public boolean report(Logger logger, Level logLevel, String msg, String meterName) { return report(logger, logLevel, msg, meterName, new String[]{}); @@ -94,8 +94,8 @@ public boolean report(Logger logger, Level logLevel, String msg, String meterNam * @param msg message string * @param meterName name of the meter * @param tags array of tags for the meter - * @see Metrics#getRegistry() * @return whether logging was performed + * @see Metrics#getRegistry() */ public boolean report(Logger logger, Level logLevel, String msg, String meterName, String[] tags) { Duration duration = Duration.between(startTime, Instant.now()); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/JSONable.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/JSONable.java index f5b103749a5..53714c7a4b5 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/JSONable.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/JSONable.java @@ -28,6 +28,9 @@ import java.util.logging.Level; +/** + * Converts Object to JSON. + */ public interface JSONable { String EMPTY = ""; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/Message.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/Message.java index 440862ce33a..ebd8b74e133 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/Message.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/Message.java @@ -52,6 +52,9 @@ public class Message implements Comparable, JSONable { @NotEmpty(message = "tags cannot be empty") private Set tags = Collections.singleton(MESSAGES_MAIN_PAGE_TAG); + /** + * Opengrok Message Level. + */ public enum MessageLevel { /** * Known values: {@code SUCCESS}, {@code INFO}, {@code WARNING}, {@code ERROR}. diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationEntityTest.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationEntityTest.java index 7ecc88451f0..d64e6cd4bac 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationEntityTest.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationEntityTest.java @@ -98,20 +98,20 @@ void testForGroupsAndForProjectsDiscovery(Function au env.getProjects().put("project 8", new Project("project 8")); env.getProjects().put("project 9", new Project("project 9")); - /** - * Structure
- *

-         * G1 + P1
-         *    + P2
-         *    + P3
-         *    + G2
-         *       + P4
-         *       + P5
-         *       + P6
-         *       + P7
-         * G3 + P8
-         *    + P9
-         * 
+ /* + Structure
+
+          G1 + P1
+             + P2
+             + P3
+             + G2
+                + P4
+                + P5
+                + P6
+                + P7
+          G3 + P8
+             + P9
+          
*/ g1 = new Group(); g1.setName("group 1"); diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/TestPlugin.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/TestPlugin.java index bdf48910513..3c4f061bb15 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/TestPlugin.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/TestPlugin.java @@ -28,6 +28,10 @@ import org.opengrok.indexer.configuration.Group; import org.opengrok.indexer.configuration.Project; +/** + * Fake IAuthorizationPlugin implementation. + * isAllowed method returns unsupported operation in this implementation. + */ public class TestPlugin implements IAuthorizationPlugin { @Override diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/EnabledForRepository.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/EnabledForRepository.java index f4aa46520d3..9a8a76bd8a6 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/EnabledForRepository.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/EnabledForRepository.java @@ -29,6 +29,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Execute a test case only if the mentioned repository is installed. + */ @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @ExtendWith({EnabledOnRepositoryCondition.class}) diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/RepositoryInstalled.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/RepositoryInstalled.java index 6e236f2311d..6049bd3bca0 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/RepositoryInstalled.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/condition/RepositoryInstalled.java @@ -33,10 +33,16 @@ import org.opengrok.indexer.history.SubversionRepository; import org.opengrok.indexer.util.LazilyInstantiate; +/** + * Type of Repositories installed to be used in Junit test cases. + */ public class RepositoryInstalled { private static final String FORCE_ALL_PROPERTY = "junit-force-all"; + /** + * Type of Repositories supported to be used in Junit test cases. + */ public enum Type { BITKEEPER(new BitKeeperRepository()), MERCURIAL(new MercurialRepository()), diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/search/context/ContextFormatterTest.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/search/context/ContextFormatterTest.java index 82662e0e695..4484ca60839 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/search/context/ContextFormatterTest.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/search/context/ContextFormatterTest.java @@ -106,9 +106,9 @@ void testLinesSpanningMatchFormatted() { p.addMatch(0, p.getEndOffset(), new BytesRef(DOC2), 1); assertEquals(1, p.getNumMatches(), "getNumMatches()"); - /** - * We're using the entire document, but see how it behaves with - * contextCount==1 + /* + We're using the entire document, but see how it behaves with + contextCount==1 */ ContextArgs args = new ContextArgs((short) 1, (short) 10); ContextFormatter fmt = new ContextFormatter(args); diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/web/messages/JSONUtils.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/web/messages/JSONUtils.java index 7f02a80406f..5123f927069 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/web/messages/JSONUtils.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/web/messages/JSONUtils.java @@ -32,6 +32,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; +/** + * Util class for Json string manipulations. + */ public final class JSONUtils { private JSONUtils() { // private to ensure static diff --git a/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java b/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java index 4850ebb31a7..dd7eec542b9 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java +++ b/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java @@ -1103,8 +1103,8 @@ public Prefix getPrefix() { * root directory (used file separators are all {@link org.opengrok.indexer.index.Indexer#PATH_SEPARATOR}). * No check is made, whether the obtained path is really an accessible resource on disk. * - * @see HttpServletRequest#getPathInfo() * @return a possible empty String (denotes the source root directory) but not {@code null}. + * @see HttpServletRequest#getPathInfo() */ public String getPath() { if (path == null) { diff --git a/opengrok-web/src/main/java/org/opengrok/web/ProjectHelper.java b/opengrok-web/src/main/java/org/opengrok/web/ProjectHelper.java index de55ebe6c0a..b1361e7ef8f 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/ProjectHelper.java +++ b/opengrok-web/src/main/java/org/opengrok/web/ProjectHelper.java @@ -291,16 +291,16 @@ public Set getGroupedRepositories() { } /** - * @see #getProjects() * @return filtered ungrouped projects + * @see #getProjects() */ public Set getUngroupedProjects() { return cacheProjects(PROJECT_HELPER_UNGROUPED_PROJECTS, ungroupedProjects); } /** - * @see #getRepositories() * @return filtered ungrouped projects + * @see #getRepositories() */ public Set getUngroupedRepositories() { return cacheProjects(PROJECT_HELPER_UNGROUPED_REPOSITORIES, ungroupedRepositories); diff --git a/opengrok-web/src/main/java/org/opengrok/web/api/v1/filter/PathAuthorized.java b/opengrok-web/src/main/java/org/opengrok/web/api/v1/filter/PathAuthorized.java index c32d5edca2b..a77dec1e580 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/api/v1/filter/PathAuthorized.java +++ b/opengrok-web/src/main/java/org/opengrok/web/api/v1/filter/PathAuthorized.java @@ -29,6 +29,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Serves for authorization of REST API endpoints that have a path parameter. + */ @NameBinding @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Authorized.java b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Authorized.java index 616604403b0..3acd2c04c9f 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Authorized.java +++ b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Authorized.java @@ -29,6 +29,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Serves for specifying api's to be authorized by authorization stack. + */ @NameBinding @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Suggester.java b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Suggester.java index 8bb9dc371ac..aa82cad170d 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Suggester.java +++ b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/filter/Suggester.java @@ -23,12 +23,16 @@ package org.opengrok.web.api.v1.suggester.provider.filter; import jakarta.ws.rs.NameBinding; +import jakarta.ws.rs.core.Response; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Annotated Api's checks if suggester is enabled and if not then returns {@link Response.Status#NOT_FOUND}. + */ @NameBinding @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/service/SuggesterService.java b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/service/SuggesterService.java index 1d02c9e5620..0d373e5724c 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/service/SuggesterService.java +++ b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/provider/service/SuggesterService.java @@ -33,6 +33,9 @@ import java.util.Map.Entry; import java.util.concurrent.TimeUnit; +/** + * Suggester Service contract definition. + */ public interface SuggesterService { /** diff --git a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java index e5ff7bb0851..4eea8dd3b5e 100644 --- a/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java +++ b/opengrok-web/src/test/java/org/opengrok/web/ProjectHelperExtendedTest.java @@ -50,13 +50,13 @@ public static void setUpClass() { List rps = env.getRepositories(); Map> map = getRepositoriesMap(); - /** - * Extend the original groups with some subgroups - structure should be - * now like this. - * - * allowed_group_2 group_1 - * / \ / \ - * group_0 allowed_group_3 group_0 allowed_group_3 + /* + Extend the original groups with some subgroups - structure should be + now like this. + + allowed_group_2 group_1 + / \ / \ + group_0 allowed_group_3 group_0 allowed_group_3 */ Group.getByName("allowed_group_2").addGroup(Group.getByName("group_0")); Group.getByName("allowed_group_2").addGroup(Group.getByName("allowed_group_3")); diff --git a/plugins/src/main/java/opengrok/auth/plugin/LdapFilterPlugin.java b/plugins/src/main/java/opengrok/auth/plugin/LdapFilterPlugin.java index 79c8e7e4f60..d1394271b33 100644 --- a/plugins/src/main/java/opengrok/auth/plugin/LdapFilterPlugin.java +++ b/plugins/src/main/java/opengrok/auth/plugin/LdapFilterPlugin.java @@ -152,15 +152,13 @@ public void fillSession(HttpServletRequest req, User user) { /** * Expand {@code LdapUser} / {@code User} object attribute values into the filter. - * - * @see opengrok.auth.plugin.util.FilterUtil - * * Use \% for printing the '%' character. * * @param filter basic filter containing the special values * @param ldapUser user from LDAP * @param user user from the request * @return the filter with replacements + * @see opengrok.auth.plugin.util.FilterUtil */ String expandFilter(String filter, LdapUser ldapUser, User user) { diff --git a/plugins/src/main/java/opengrok/auth/plugin/LdapUserPlugin.java b/plugins/src/main/java/opengrok/auth/plugin/LdapUserPlugin.java index 5e6639c99df..9d432047880 100644 --- a/plugins/src/main/java/opengrok/auth/plugin/LdapUserPlugin.java +++ b/plugins/src/main/java/opengrok/auth/plugin/LdapUserPlugin.java @@ -128,13 +128,11 @@ protected boolean sessionExists(HttpServletRequest req) { /** * Expand {@code User} object attribute values into the filter. - * - * @see opengrok.auth.plugin.util.FilterUtil - * * Use \% for printing the '%' character. * * @param user User object from the request (created by {@code UserPlugin}) * @return replaced result + * @see opengrok.auth.plugin.util.FilterUtil */ String expandFilter(User user) { String filter = ldapFilter; diff --git a/plugins/src/main/java/opengrok/auth/plugin/util/Timestamp.java b/plugins/src/main/java/opengrok/auth/plugin/util/Timestamp.java index 90096439415..2bfae46f874 100644 --- a/plugins/src/main/java/opengrok/auth/plugin/util/Timestamp.java +++ b/plugins/src/main/java/opengrok/auth/plugin/util/Timestamp.java @@ -27,10 +27,10 @@ /** * Implementation of timestamp decoding. * + * @author Krystof Tulinger * @see mod_osso documentation * chapter 9.5 * - * @author Krystof Tulinger */ public class Timestamp { diff --git a/pom.xml b/pom.xml index cbf95dde681..4b997d1a2d0 100644 --- a/pom.xml +++ b/pom.xml @@ -359,12 +359,12 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . org.apache.maven.plugins maven-checkstyle-plugin - 3.2.2 + 3.3.1 com.puppycrawl.tools checkstyle - 9.3 + 10.12.4 diff --git a/suggester/src/main/java/org/opengrok/suggest/query/SuggesterRangeQuery.java b/suggester/src/main/java/org/opengrok/suggest/query/SuggesterRangeQuery.java index 12cc3a0326b..db023b0d7b5 100644 --- a/suggester/src/main/java/org/opengrok/suggest/query/SuggesterRangeQuery.java +++ b/suggester/src/main/java/org/opengrok/suggest/query/SuggesterRangeQuery.java @@ -142,6 +142,9 @@ public int hashCode() { return Objects.hash(super.hashCode(), suggestPosition); } + /** + * SuggestPosition type values. + */ public enum SuggestPosition { LOWER, UPPER }