Skip to content

Commit

Permalink
Add check for trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ahornace authored and Vladimir Kotal committed Jul 20, 2021
1 parent 917059f commit 0e4c555
Show file tree
Hide file tree
Showing 155 changed files with 587 additions and 597 deletions.
7 changes: 7 additions & 0 deletions dev/checkstyle/style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
<module name="FileLength"/>
<module name="FileTabCharacter"/>

<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>

<module name="LineLength">
<property name="max" value="150"/>
</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public class AnalyzerGuru {
* List of all registered {@code FileAnalyzerFactory} instances.
*/
private static final List<AnalyzerFactory> factories = new ArrayList<>();

/**
* Names of all analysis packages.
*/
Expand Down Expand Up @@ -768,35 +768,35 @@ public static AnalyzerFactory findByFileTypeName(String fileTypeName) {
* @throws InvocationTargetException if the underlying constructor throws an exception
*/
public static AnalyzerFactory findFactory(String factoryClassName)
throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException,
throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException,
InvocationTargetException {
Class<?> fcn;
try {
fcn = Class.forName(factoryClassName);

} catch (ClassNotFoundException e) {
fcn = getFactoryClass(factoryClassName);

if (fcn == null) {
throw new ClassNotFoundException("Unable to locate class " + factoryClassName);
}
}

return findFactory(fcn);
}

/**
* Get Analyzer factory class using class simple name.
*
*
* @param simpleName which may be either the factory class
* simple name (eg. CAnalyzerFactory), the analyzer name
* (eg. CAnalyzer), or the language name (eg. C)
*
*
* @return the analyzer factory class, or null when not found.
*/
public static Class<?> getFactoryClass(String simpleName) {
Class<?> factoryClass = null;

// Build analysis package name list first time only
if (analysisPkgNames.isEmpty()) {
Package[] p = Package.getPackages();
Expand All @@ -807,17 +807,17 @@ public static Class<?> getFactoryClass(String simpleName) {
}
}
}

// This allows user to enter the language or analyzer name
// (eg. C or CAnalyzer vs. CAnalyzerFactory)
// Note that this assumes a regular naming scheme of
// all language parsers:
// all language parsers:
// <language>Analyzer, <language>AnalyzerFactory

if (!simpleName.contains("Analyzer")) {
simpleName += "Analyzer";
}

if (!simpleName.contains("Factory")) {
simpleName += "Factory";
}
Expand All @@ -831,10 +831,10 @@ public static Class<?> getFactoryClass(String simpleName) {
// Ignore
}
}

return factoryClass;
}

/**
* Find a {@code FileAnalyzerFactory} which is an instance of the specified
* class. If one doesn't exist, create one and register it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected TokenStreamComponents createComponents(String fieldName) {
try (HistoryAnalyzer historyAnalyzer = new HistoryAnalyzer()) {
return historyAnalyzer.createComponents(fieldName);
}
//below is set by PlainAnalyzer to workaround #1376 symbols search works like full text search
//below is set by PlainAnalyzer to workaround #1376 symbols search works like full text search
case QueryBuilder.REFS: {
return new TokenStreamComponents(symbolTokenizerFactory.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ public HistoryAnalyzer() {
super(Analyzer.PER_FIELD_REUSE_STRATEGY);
stopWords = StopFilter.makeStopSet(ENGLISH_STOP_WORDS);
}

/**
* Creates components using a new {@link PlainFullTokenizer}, filtered using
* a default set of English stop-words.
* @param fieldName name of field for which to create components
* @param fieldName name of field for which to create components
* @return components for this analyzer (NB safe to use even if this
* analyzer were to be garbage-collected)
*/
@Override
protected TokenStreamComponents createComponents(String fieldName) {
protected TokenStreamComponents createComponents(String fieldName) {
JFlexTokenizer plainfull = new JFlexTokenizer(new PlainFullTokenizer(
AbstractAnalyzer.DUMMY_READER));
//we are counting position increments, this might affect the queries
//later and need to be in sync, especially for highlighting of results
return new TokenStreamComponents(plainfull, new StopFilter(plainfull,
stopWords));
}

@Override
protected TokenStream normalize(String fieldName, TokenStream in) {
protected TokenStream normalize(String fieldName, TokenStream in) {
return new LowerCaseFilter(in);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ protected boolean writeSymbol(String symbol, Set<String> keywords, int line,
boolean caseSensitive) throws IOException {
return writeSymbol(symbol, keywords, line, caseSensitive, false);
}

/**
* Write a symbol and generate links as appropriate.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
public class PathTokenizer extends Tokenizer {

// below should be '/' since we try to convert even windows file separators
// below should be '/' since we try to convert even windows file separators
// to unix ones
public static final char DEFAULT_DELIMITER = '/';
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
*/
public class AdaAnalyzerFactory extends FileAnalyzerFactory {

private static final String name = "Ada";
private static final String NAME = "Ada";

private static final String[] SUFFIXES = {
"ADA",
"ADB",
"ADS"
};

public AdaAnalyzerFactory() {
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, name);
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class Consts {
kwd.add("while");
kwd.add("with");
kwd.add("xor");

kwd.add("ascii"); // A.1 The Package Standard
kwd.add("base"); // A.1 The Package Standard
kwd.add("boolean"); // A.1 The Package Standard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,5 @@ public InputStream getStream() throws IOException {
}
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.opengrok.indexer.analysis.FileAnalyzerFactory;

public class BZip2AnalyzerFactory extends FileAnalyzerFactory {
private static final String name = "Bzip(2)";

private static final String NAME = "Bzip(2)";

private static final String[] SUFFIXES = {
"BZ", "BZ2"
};
Expand All @@ -38,7 +38,7 @@ public class BZip2AnalyzerFactory extends FileAnalyzerFactory {
};

public BZip2AnalyzerFactory() {
super(null, null, SUFFIXES, MAGICS, null, null, null, name);
super(null, null, SUFFIXES, MAGICS, null, null, null, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ public InputStream getStream() throws IOException {
new GZIPInputStream(src.getStream()));
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.opengrok.indexer.analysis.FileAnalyzerFactory;

public class GZIPAnalyzerFactory extends FileAnalyzerFactory {
private static final String name = "GZIP";

private static final String NAME = "GZIP";

private static final String[] SUFFIXES = {
"GZ"
};
Expand All @@ -38,7 +38,7 @@ public class GZIPAnalyzerFactory extends FileAnalyzerFactory {
};

public GZIPAnalyzerFactory() {
super(null, null, SUFFIXES, MAGICS, null, null, null, name);
super(null, null, SUFFIXES, MAGICS, null, null, null, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
import org.opengrok.indexer.analysis.FileAnalyzerFactory;

public class TarAnalyzerFactory extends FileAnalyzerFactory {
private static final String name = "Tar";

private static final String NAME = "Tar";

private static final String[] SUFFIXES = {
"TAR"
};

public TarAnalyzerFactory() {
super(null, null, SUFFIXES, null, null, null, AbstractAnalyzer.Genre.XREFABLE, name);
super(null, null, SUFFIXES, null, null, null, AbstractAnalyzer.Genre.XREFABLE, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.opengrok.indexer.analysis.FileAnalyzerFactory;

public final class ZipAnalyzerFactory extends FileAnalyzerFactory {
private static final String name = "Zip";

private static final String NAME = "Zip";

private static final String[] SUFFIXES = {
"ZIP"
};
Expand All @@ -57,7 +57,7 @@ protected boolean doesCheckExtraFieldID() {
new ZipAnalyzerFactory();

private ZipAnalyzerFactory() {
super(null, null, SUFFIXES, null, MATCHER, null, AbstractAnalyzer.Genre.XREFABLE, name);
super(null, null, SUFFIXES, null, MATCHER, null, AbstractAnalyzer.Genre.XREFABLE, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected int getSpecializedVersionNo() {
protected JFlexXref newXref(Reader reader) {
return new JFlexXref(new CXref(reader));
}

@Override
protected boolean supportsScopes() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import org.opengrok.indexer.analysis.FileAnalyzerFactory;

public class CAnalyzerFactory extends FileAnalyzerFactory {
private static final String name = "C";

private static final String NAME = "C";

private static final String[] SUFFIXES = {
"C",
"H",
Expand All @@ -44,7 +44,7 @@ public class CAnalyzerFactory extends FileAnalyzerFactory {
};

public CAnalyzerFactory() {
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, name);
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected int getSpecializedVersionNo() {
protected JFlexXref newXref(Reader reader) {
return new JFlexXref(new CxxXref(reader));
}

@Override
protected boolean supportsScopes() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class ClojureAnalyzerFactory extends FileAnalyzerFactory {

private static final String name = "Clojure";
private static final String NAME = "Clojure";

private static final String[] SUFFIXES = {
"CLJ",
Expand All @@ -36,7 +36,7 @@ public class ClojureAnalyzerFactory extends FileAnalyzerFactory {
};

public ClojureAnalyzerFactory() {
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, name);
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected int getSpecializedVersionNo() {
protected JFlexXref newXref(Reader reader) {
return new JFlexXref(new CSharpXref(reader));
}

@Override
protected boolean supportsScopes() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import org.opengrok.indexer.analysis.FileAnalyzerFactory;

public class CSharpAnalyzerFactory extends FileAnalyzerFactory {
private static final String name = "C#";

private static final String NAME = "C#";

private static final String[] SUFFIXES = {
"CS"
};

public CSharpAnalyzerFactory() {
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, name);
super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class IgnorantAnalyzerFactory extends FileAnalyzerFactory {
"%PDF",
"Microsoft C/C++ MSF ", // PDB files: https://msdn.microsoft.com/en-us/library/yd4f8bd1(vs.71).aspx
"!<arch>", // LIB files: https://msdn.microsoft.com/en-us/library/ba1z7822.aspx

};

public IgnorantAnalyzerFactory() {
Expand Down
Loading

0 comments on commit 0e4c555

Please sign in to comment.