Merge branch 'pr/3657' into 7.0.x

This commit is contained in:
Clément Fournier committed 2022-02-06 15:58:48 +01:00
commit b93dfb72f9
130 files changed
+394 -509

No files matched your search

+31 -16
View File
@@ -33,6 +33,23 @@ function build() {
./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
pmd_ci_log_group_end
if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then
pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}"
./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}-dogfood" -DgenerateBackupPoms=false
sed -i 's/<version>[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}.*<\/version>\( *<!-- pmd.dogfood.version -->\)/<version>'"${PMD_CI_MAVEN_PROJECT_VERSION}"'<\/version>\1/' pom.xml
if [ "${PMD_CI_MAVEN_PROJECT_VERSION}" = "7.0.0-SNAPSHOT" ]; then
sed -i 's/pmd-dogfood-config\.xml/pmd-dogfood-config7.xml/' pom.xml
fi
./mvnw verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" \
-DskipTests \
-Dmaven.javadoc.skip=true \
-Dmaven.source.skip=true \
-Dcheckstyle.skip=true
./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}" -DgenerateBackupPoms=false
git checkout -- pom.xml
pmd_ci_log_group_end
fi
# Danger is executed only on the linux runner
if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then
pmd_ci_log_group_start "Executing danger"
@@ -87,22 +104,20 @@ function build() {
pmd_ci_log_group_end
if pmd_ci_maven_isSnapshotBuild; then
if [ "${PMD_CI_MAVEN_PROJECT_VERSION}" != "7.0.0-SNAPSHOT" ]; then
pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}"
./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}-dogfood" -DgenerateBackupPoms=false
sed -i 's/<version>[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}.*<\/version>\( *<!-- pmd.dogfood.version -->\)/<version>'"${PMD_CI_MAVEN_PROJECT_VERSION}"'<\/version>\1/' pom.xml
./mvnw verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" \
-DskipTests \
-Dmaven.javadoc.skip=true \
-Dmaven.source.skip=true \
-Dcheckstyle.skip=true
./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}" -DgenerateBackupPoms=false
git checkout -- pom.xml
pmd_ci_log_group_end
else
# current maven-pmd-plugin is not compatible with PMD 7 yet.
pmd_ci_log_info "Skipping PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}"
fi
pmd_ci_log_group_start "Executing PMD dogfood test with ${PMD_CI_MAVEN_PROJECT_VERSION}"
./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}-dogfood" -DgenerateBackupPoms=false
sed -i 's/<version>[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}.*<\/version>\( *<!-- pmd.dogfood.version -->\)/<version>'"${PMD_CI_MAVEN_PROJECT_VERSION}"'<\/version>\1/' pom.xml
if [ "${PMD_CI_MAVEN_PROJECT_VERSION}" = "7.0.0-SNAPSHOT" ]; then
sed -i 's/pmd-dogfood-config\.xml/pmd-dogfood-config7.xml/' pom.xml
fi
./mvnw verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}" \
-DskipTests \
-Dmaven.javadoc.skip=true \
-Dmaven.source.skip=true \
-Dcheckstyle.skip=true
./mvnw versions:set -DnewVersion="${PMD_CI_MAVEN_PROJECT_VERSION}" -DgenerateBackupPoms=false
git checkout -- pom.xml
pmd_ci_log_group_end
pmd_ci_log_group_start "Executing build with sonar"
# Note: Sonar also needs GITHUB_TOKEN (!)
@@ -46,7 +46,7 @@ public class ApexHandler extends AbstractPmdLanguageVersionHandler {
return myMetricsProvider;
}
private static class ApexMetricsProvider implements LanguageMetricsProvider {
private static final class ApexMetricsProvider implements LanguageMetricsProvider {
private final Set<Metric<?, ?>> metrics = setOf(
ApexMetrics.COGNITIVE_COMPLEXITY,
@@ -7,13 +7,14 @@ package net.sourceforge.pmd.lang.apex.ast;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.AbstractList;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.RandomAccess;
import java.util.Stack;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.Token;
@@ -239,10 +240,10 @@ final class ApexTreeBuilder extends AstVisitor<AdditionalPassScope> {
}
// The nodes having children built.
private final Stack<AbstractApexNode<?>> nodes = new Stack<>();
private final Deque<AbstractApexNode<?>> nodes = new ArrayDeque<>();
// The Apex nodes with children to build.
private final Stack<AstNode> parents = new Stack<>();
private final Deque<AstNode> parents = new ArrayDeque<>();
private final AdditionalPassScope scope = new AdditionalPassScope(Errors.createErrors());
@@ -393,6 +394,7 @@ final class ApexTreeBuilder extends AstVisitor<AdditionalPassScope> {
ANTLRStringStream stream = new ANTLRStringStream(source);
ApexLexer lexer = new ApexLexer(stream);
@SuppressWarnings("PMD.LooseCoupling") // allCommentTokens must be ArrayList explicitly to guarantee RandomAccess
ArrayList<TokenLocation> allCommentTokens = new ArrayList<>();
List<ApexDocTokenLocation> tokenLocations = new ArrayList<>();
Map<Integer, String> suppressMap = new HashMap<>();
@@ -441,6 +443,7 @@ final class ApexTreeBuilder extends AstVisitor<AdditionalPassScope> {
final Map<Integer, String> suppressMap;
final List<TokenLocation> allCommentTokens;
@SuppressWarnings("PMD.LooseCoupling") // must be concrete class in order to guarantee RandomAccess
final TokenListByStartIndex allCommentTokensByStartIndex;
final List<ApexDocTokenLocation> docTokenLocations;
@@ -11,7 +11,6 @@ import net.sourceforge.pmd.lang.apex.ast.ASTDoLoopStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTForEachStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTForLoopStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTIfBlockStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTStandardCondition;
import net.sourceforge.pmd.lang.apex.ast.ASTTernaryExpression;
import net.sourceforge.pmd.lang.apex.ast.ASTThrowStatement;
@@ -23,12 +22,6 @@ import net.sourceforge.pmd.lang.apex.ast.ApexVisitorBase;
*/
public class StandardCycloVisitor extends ApexVisitorBase<MutableInt, Void> {
@Override
public Void visit(ASTMethod node, MutableInt data) {
return super.visit(node, data);
}
@Override
public Void visit(ASTIfBlockStatement node, MutableInt data) {
data.add(1 + ApexMetricsHelper.booleanExpressionComplexity(node.getFirstDescendantOfType(ASTStandardCondition.class)));
@@ -55,7 +55,7 @@ public abstract class AbstractNcssCountRule<T extends ApexNode<?>> extends Abstr
return node.acceptVisitor(NcssVisitor.INSTANCE, null) + 1;
}
private static class NcssVisitor extends ApexVisitorBase<Void, Integer> {
private static final class NcssVisitor extends ApexVisitorBase<Void, Integer> {
// todo this would be better with a <MutableInt, Void> signature
static final NcssVisitor INSTANCE = new NcssVisitor();
@@ -6,7 +6,8 @@ package net.sourceforge.pmd.lang.apex.rule.design;
import static net.sourceforge.pmd.properties.constraints.NumericConstraints.positive;
import java.util.Stack;
import java.util.ArrayDeque;
import java.util.Deque;
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
@@ -33,7 +34,7 @@ public class CognitiveComplexityRule extends AbstractApexRule {
.defaultValue(15)
.build();
private Stack<String> classNames = new Stack<>();
private Deque<String> classNames = new ArrayDeque<>();
private boolean inTrigger;
@@ -7,7 +7,8 @@ package net.sourceforge.pmd.lang.apex.rule.design;
import static net.sourceforge.pmd.properties.constraints.NumericConstraints.positive;
import java.util.Stack;
import java.util.ArrayDeque;
import java.util.Deque;
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
@@ -40,7 +41,7 @@ public class CyclomaticComplexityRule extends AbstractApexRule {
.defaultValue(10)
.build();
private Stack<String> classNames = new Stack<>();
private Deque<String> classNames = new ArrayDeque<>();
private boolean inTrigger;
@@ -7,8 +7,10 @@ package net.sourceforge.pmd.lang.apex.rule.design;
import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty;
import static net.sourceforge.pmd.properties.constraints.NumericConstraints.inRange;
import java.util.Stack;
import java.util.ArrayDeque;
import java.util.Deque;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.apex.ast.ASTBooleanExpression;
import net.sourceforge.pmd.lang.apex.ast.ASTDoLoopStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTForEachStatement;
@@ -55,7 +57,7 @@ public class StdCyclomaticComplexityRule extends AbstractApexRule {
private boolean showClassesComplexity = true;
private boolean showMethodsComplexity = true;
protected static class Entry {
protected static final class Entry {
private int decisionPoints = 1;
public int highestDecisionPoints;
public int methodCount;
@@ -76,7 +78,7 @@ public class StdCyclomaticComplexityRule extends AbstractApexRule {
}
}
protected Stack<Entry> entryStack = new Stack<>();
protected Deque<Entry> entryStack = new ArrayDeque<>();
public StdCyclomaticComplexityRule() {
definePropertyDescriptor(REPORT_LEVEL_DESCRIPTOR);
@@ -85,10 +87,14 @@ public class StdCyclomaticComplexityRule extends AbstractApexRule {
}
@Override
public Object visit(ASTUserClass node, Object data) {
public void start(RuleContext ctx) {
reportLevel = getProperty(REPORT_LEVEL_DESCRIPTOR);
showClassesComplexity = getProperty(SHOW_CLASSES_COMPLEXITY_DESCRIPTOR);
showMethodsComplexity = getProperty(SHOW_METHODS_COMPLEXITY_DESCRIPTOR);
}
@Override
public Object visit(ASTUserClass node, Object data) {
entryStack.push(new Entry());
super.visit(node, data);
Entry classEntry = entryStack.pop();
@@ -103,9 +109,6 @@ public class StdCyclomaticComplexityRule extends AbstractApexRule {
@Override
public Object visit(ASTUserTrigger node, Object data) {
reportLevel = getProperty(REPORT_LEVEL_DESCRIPTOR);
showClassesComplexity = getProperty(SHOW_CLASSES_COMPLEXITY_DESCRIPTOR);
showMethodsComplexity = getProperty(SHOW_METHODS_COMPLEXITY_DESCRIPTOR);
entryStack.push(new Entry());
super.visit(node, data);
Entry classEntry = entryStack.pop();
@@ -183,7 +183,7 @@ public class ApexDocRule extends AbstractApexRule {
boolean hasDescription = DESCRIPTION_PATTERN.matcher(token).find();
boolean hasReturn = RETURN_PATTERN.matcher(token).find();
ArrayList<String> params = new ArrayList<>();
List<String> params = new ArrayList<>();
Matcher paramMatcher = PARAM_PATTERN.matcher(token);
while (paramMatcher.find()) {
params.add(paramMatcher.group(1));
@@ -91,7 +91,7 @@ public final class Helper {
return reference != null && reference.getNames().size() == 1
&& reference.getNames().get(0).equalsIgnoreCase(className)
&& (methodName.equals(ANY_METHOD) || isMethodName(methodNode, methodName));
&& (ANY_METHOD.equals(methodName) || isMethodName(methodNode, methodName));
}
public static boolean isMethodName(final ASTMethodCallExpression m, final String methodName) {
@@ -414,7 +414,7 @@ public class ApexCRUDViolationRule extends AbstractApexRule {
private boolean isLastMethodName(final ASTMethodCallExpression methodNode, final String className,
final String methodName) {
final ASTReferenceExpression reference = methodNode.getFirstChildOfType(ASTReferenceExpression.class);
if (reference != null && reference.getNames().size() > 0) {
if (reference != null && !reference.getNames().isEmpty()) {
if (reference.getNames().get(reference.getNames().size() - 1)
.equalsIgnoreCase(className) && Helper.isMethodName(methodNode, methodName)) {
return true;
@@ -425,15 +425,13 @@ public class ApexCRUDViolationRule extends AbstractApexRule {
}
private boolean isWithSecurityEnforced(final ApexNode<?> node) {
if (node instanceof ASTSoqlExpression) {
return WITH_SECURITY_ENFORCED.matcher(((ASTSoqlExpression) node).getQuery()).matches();
}
return false;
return node instanceof ASTSoqlExpression
&& WITH_SECURITY_ENFORCED.matcher(((ASTSoqlExpression) node).getQuery()).matches();
}
private String getType(final ASTMethodCallExpression methodNode) {
final ASTReferenceExpression reference = methodNode.getFirstChildOfType(ASTReferenceExpression.class);
if (reference.getNames().size() > 0) {
if (!reference.getNames().isEmpty()) {
return new StringBuilder().append(reference.getDefiningType()).append(":")
.append(reference.getNames().get(0)).toString();
}
@@ -524,7 +522,7 @@ public class ApexCRUDViolationRule extends AbstractApexRule {
}
// some methods might be within this class
mapCallToMethodDecl(self, innerMethodCalls, new ArrayList<ASTMethodCallExpression>(innerMethodCalls));
mapCallToMethodDecl(self, innerMethodCalls, new ArrayList<>(innerMethodCalls));
}
return innerMethodCalls;
@@ -577,7 +575,7 @@ public class ApexCRUDViolationRule extends AbstractApexRule {
}
private List<ASTMethod> findConstructorMethods() {
final ArrayList<ASTMethod> ret = new ArrayList<>();
final List<ASTMethod> ret = new ArrayList<>();
final Set<String> constructors = classMethods.keySet().stream()
.filter(p -> p.contains("<init>") || p.contains("<clinit>")
|| p.startsWith(className + ":" + className + ":")).collect(Collectors.toSet());
@@ -220,7 +220,7 @@ public class ApexSOQLInjectionRule extends AbstractApexRule {
}
private void reportStrings(ASTMethodCallExpression m, Object data) {
final HashSet<ASTVariableExpression> setOfSafeVars = new HashSet<>();
final Set<ASTVariableExpression> setOfSafeVars = new HashSet<>();
final List<ASTStandardCondition> conditions = m.findDescendantsOfType(ASTStandardCondition.class);
for (ASTStandardCondition c : conditions) {
List<ASTVariableExpression> vars = c.findDescendantsOfType(ASTVariableExpression.class);
@@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.apex.rule.security;
import java.util.Map;
import java.util.Optional;
import java.util.WeakHashMap;
@@ -33,7 +34,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule {
/**
* Keep track of previously reported violations to avoid duplicates.
*/
private WeakHashMap<ApexNode<?>, Object> localCacheOfReportedNodes = new WeakHashMap<>();
private Map<ApexNode<?>, Object> localCacheOfReportedNodes = new WeakHashMap<>();
public ApexSharingViolationsRule() {
addRuleChainVisit(ASTDmlDeleteStatement.class);
@@ -64,7 +64,7 @@ public final class Helper {
return reference != null && reference.getNames().size() == 1
&& reference.getNames().get(0).equalsIgnoreCase(className)
&& (methodName.equals(ANY_METHOD) || isMethodName(methodNode, methodName));
&& (ANY_METHOD.equals(methodName) || isMethodName(methodNode, methodName));
}
static boolean isMethodName(final ASTMethodCallExpression m, final String methodName) {
@@ -205,7 +205,7 @@ public class PMD {
try {
Renderer renderer;
final List<Renderer> renderers;
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) {
renderer = configuration.createRenderer();
renderers = Collections.singletonList(renderer);
renderer.setReportFile(configuration.getReportFile());
@@ -213,11 +213,11 @@ public class PMD {
}
Report report;
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.FILE_PROCESSING)) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.FILE_PROCESSING)) {
report = processFiles(configuration, Arrays.asList(ruleSets.getAllRuleSets()), files, renderers);
}
try (TimedOperation rto = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) {
renderer.end();
renderer.flush();
return report.getViolations().size();
@@ -245,7 +245,7 @@ public class PMD {
}
private static List<RuleSet> getRuleSetsWithBenchmark(List<String> rulesetPaths, RuleSetLoader factory) {
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.LOAD_RULES)) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.LOAD_RULES)) {
List<RuleSet> ruleSets;
try {
ruleSets = factory.loadFromResources(rulesetPaths);
@@ -384,7 +384,7 @@ public class PMD {
* @return List of {@link DataSource} of files
*/
public static List<DataSource> getApplicableFiles(PMDConfiguration configuration, Set<Language> languages) {
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.COLLECT_FILES)) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.COLLECT_FILES)) {
return internalGetApplicableFiles(configuration, languages);
}
}
@@ -621,7 +621,7 @@ public class PMD {
}
private static class AcceptAllFilenames implements FilenameFilter {
private static final class AcceptAllFilenames implements FilenameFilter {
@Override
public boolean accept(File dir, String name) {
return true;
@@ -140,7 +140,7 @@ final class RuleSetFactoryCompatibility {
return result;
}
private static class RuleSetFilter {
private static final class RuleSetFilter {
private static final String MOVED_MESSAGE = "The rule \"{1}\" has been moved from ruleset \"{0}\" to \"{2}\". Please change your ruleset!";
private static final String RENAMED_MESSAGE = "The rule \"{1}\" has been renamed to \"{3}\". Please change your ruleset!";
@@ -232,7 +232,7 @@ public class RuleSetReferenceId {
private boolean checkRulesetExists(final String name) {
boolean resourceFound = false;
if (name != null) {
try (InputStream resource = new ResourceLoader().loadClassPathResourceAsStreamOrThrow(name)) {
try (InputStream ignored = new ResourceLoader().loadClassPathResourceAsStreamOrThrow(name)) {
resourceFound = true;
} catch (Exception ignored) {
// ignored
@@ -295,11 +295,7 @@ public class RuleSetReferenceId {
private static boolean isHttpUrl(String name) {
String stripped = StringUtils.strip(name);
if (stripped == null) {
return false;
}
return stripped.startsWith("http://") || stripped.startsWith("https://");
return stripped != null && (stripped.startsWith("http://") || stripped.startsWith("https://"));
}
private static boolean isValidUrl(String name) {
@@ -141,7 +141,7 @@ public class RuleSets {
this.ruleApplicator = prepareApplicator();
}
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.RULE_AST_INDEXATION)) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.RULE_AST_INDEXATION)) {
ruleApplicator.index(acuList);
}
@@ -134,8 +134,7 @@ public class Formatter {
}
private static String[] validRendererCodes() {
return RendererFactory.REPORT_FORMAT_TO_RENDERER.keySet()
.toArray(new String[RendererFactory.REPORT_FORMAT_TO_RENDERER.size()]);
return RendererFactory.REPORT_FORMAT_TO_RENDERER.keySet().toArray(new String[0]);
}
private static String unknownRendererMessage(String userSpecifiedType) {
@@ -245,10 +245,7 @@ public final class TimeTracker {
return false;
}
TimedOperationKey other = (TimedOperationKey) obj;
if (category != other.category) {
return false;
}
return Objects.equals(label, other.label);
return category == other.category && Objects.equals(label, other.label);
}
@Override
@@ -260,7 +257,7 @@ public final class TimeTracker {
/**
* A standard timed operation implementation.
*/
private static class TimedOperationImpl implements TimedOperation {
private static final class TimedOperationImpl implements TimedOperation {
private boolean closed = false;
@Override
@@ -64,7 +64,7 @@ public abstract class AbstractAnalysisCache implements AnalysisCache {
@Override
public boolean isUpToDate(final File sourceFile) {
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "up-to-date check")) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "up-to-date check")) {
// There is a new file being analyzed, prepare entry in updated cache
final AnalysisResult updatedResult = new AnalysisResult(sourceFile);
updatedResultsCache.put(sourceFile.getPath(), updatedResult);
@@ -116,7 +116,7 @@ public abstract class AbstractAnalysisCache implements AnalysisCache {
@Override
public void checkValidity(final RuleSets ruleSets, final ClassLoader auxclassPathClassLoader) {
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "validity check")) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "validity check")) {
boolean cacheIsValid = cacheExists();
if (cacheIsValid && ruleSets.getChecksum() != rulesetChecksum) {
@@ -36,7 +36,7 @@ public class AnalysisResult {
}
public AnalysisResult(final File sourceFile) {
this(computeFileChecksum(sourceFile), new ArrayList<RuleViolation>());
this(computeFileChecksum(sourceFile), new ArrayList<>());
}
private static long computeFileChecksum(final File sourceFile) {
@@ -56,7 +56,7 @@ public class FileAnalysisCache extends AbstractAnalysisCache {
* @param cacheFile The file which backs the file analysis cache.
*/
private void loadFromFile(final File cacheFile) {
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "load")) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "load")) {
if (cacheExists()) {
try (
DataInputStream inputStream = new DataInputStream(
@@ -103,7 +103,7 @@ public class FileAnalysisCache extends AbstractAnalysisCache {
@Override
public void persist() {
try (TimedOperation to = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "persist")) {
try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "persist")) {
if (cacheFile.isDirectory()) {
LOG.severe("Cannot persist the cache, the given path points to a directory.");
return;
@@ -245,7 +245,7 @@ public class CPDConfiguration extends AbstractConfiguration {
}
public static String[] getRenderers() {
String[] result = RENDERERS.keySet().toArray(new String[RENDERERS.size()]);
String[] result = RENDERERS.keySet().toArray(new String[0]);
Arrays.sort(result);
return result;
}
@@ -245,14 +245,14 @@ public class GUI implements CPDListener {
return LANGUAGE_CONFIGS_BY_LABEL.get(label);
}
private static class CancelListener implements ActionListener {
private static final class CancelListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
private class GoListener implements ActionListener {
private final class GoListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@@ -308,7 +308,7 @@ public class GUI implements CPDListener {
}
private class BrowseListener implements ActionListener {
private final class BrowseListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser(rootDirectoryField.getText());
@@ -43,7 +43,7 @@ public final class LanguageFactory extends LanguageServiceBase<Language> {
public static String[] supportedLanguages;
static {
supportedLanguages = INSTANCE.languagesByTerseName.keySet().toArray(new String[INSTANCE.languages.size()]);
supportedLanguages = INSTANCE.languagesByTerseName.keySet().toArray(new String[0]);
}
private LanguageFactory() {
@@ -14,7 +14,6 @@ import java.util.Map;
public class MatchAlgorithm {
private static final int MOD = 37;
private int lastHash;
private int lastMod = 1;
private List<Match> matches;
@@ -91,6 +90,7 @@ public class MatchAlgorithm {
@SuppressWarnings("PMD.JumbledIncrementer")
private Map<TokenEntry, Object> hash() {
int lastHash = 0;
Map<TokenEntry, Object> markGroups = new HashMap<>(tokens.size());
for (int i = code.size() - 1; i >= 0; i--) {
TokenEntry token = code.get(i);
@@ -83,10 +83,7 @@ public class MatchCollector {
}
private boolean hasPreviousDupe(TokenEntry mark1, TokenEntry mark2) {
if (mark1.getIndex() == 0) {
return false;
}
return !matchEnded(ma.tokenAt(-1, mark1), ma.tokenAt(-1, mark2));
return mark1.getIndex() != 0 && !matchEnded(ma.tokenAt(-1, mark1), ma.tokenAt(-1, mark2));
}
private int countDuplicateTokens(TokenEntry mark1, TokenEntry mark2) {
@@ -126,7 +126,7 @@ public abstract class BaseTokenFilter<T extends GenericToken<T>> implements Toke
return currentToken.isEof();
}
private class RemainingTokens implements Iterable<T> {
private final class RemainingTokens implements Iterable<T> {
@Override
public Iterator<T> iterator() {
@@ -65,7 +65,7 @@ public class DocumentOperationsApplierForNonOverlappingRegions {
}
}
private static class DocumentOperationNonOverlappingRegionsComparator implements Comparator<DocumentOperation> {
private static final class DocumentOperationNonOverlappingRegionsComparator implements Comparator<DocumentOperation> {
@Override
public int compare(final DocumentOperation o1, final DocumentOperation o2) {
Loaded 30 of 130 files, more files were not shown because too many files have changed in this diff. Show more