Skip to content

Commit

Permalink
Upgrade checkstyle and add new rules
Browse files Browse the repository at this point in the history
Signed-off-by: Gino Augustine <ginoaugustine@gmail.com>
  • Loading branch information
ginoaugustine authored and vladak committed Nov 14, 2023
1 parent 8dfcae7 commit e348042
Show file tree
Hide file tree
Showing 43 changed files with 193 additions and 138 deletions.
7 changes: 7 additions & 0 deletions dev/checkstyle/style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
</module>

<module name="TreeWalker">
<module name="InvalidJavadocPosition"/>
<module name="JavadocStyle"/>
<module name="AtclauseOrder"/>
<module name="MissingJavadocType">
<property name="tokens"
value="INTERFACE_DEF, ENUM_DEF,
RECORD_DEF, ANNOTATION_DEF"/>
</module>
<module name="AvoidStarImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,13 @@ protected void processTargetGroupsAndProjects() {
Set<String> 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) {
Expand All @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <b>always</b> 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
<b>always</b> 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()) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,19 +642,18 @@ public Map<String, String> 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(
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import java.io.File;

/**
* Annotation Cache Related Operations.
*/
public interface AnnotationCache extends Cache {
/**
* Retrieve annotation from cache.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,14 +783,14 @@ public boolean fillLastHistoryEntries(File directory, List<DirectoryEntry> 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
* @param depth maximum scanning depth
* @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<RepositoryInfo> addRepositories(File[] files, int allowedNesting, int depth, boolean isNested,
Progress progress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/**
* A History Parser for Razor.
*
* @author Peter Bray <Peter.Darren.Bray@gmail.com>
* @author Peter Bray &lt;Peter.Darren.Bray@gmail.com&gt;
*/
class RazorHistoryParser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ TreeSet<TagEntry> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getAllFiles(List<String> subFiles) throws IOException {
Set<String> files = new HashSet<>();
Expand Down Expand Up @@ -1940,8 +1940,8 @@ public static Set<String> getAllFiles(List<String> 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<String> getFiles() throws IOException {
IndexReader ireader = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ public Map<String, String> getQueries() {
*/
public List<String> getContextFields() {
List<String> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ public void results(int start, int end, List<Hit> 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ public Object format(Passage[] passages, String originalText) {
finishLine(bld, lhi.getLineno(), marks);
// Regardless of true EOL, write a <br/>.
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);
Expand Down
Loading

0 comments on commit e348042

Please sign in to comment.