Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pmd.check.version from 6.55.0 to 7.0.0-rc4 #188

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private RuleSet getRuleSet2() throws RuleSetLoadException {
return this.ruleSet2;
}

private static class RulesetLoaderMessageReporter implements MessageReporter {
private static final class RulesetLoaderMessageReporter implements MessageReporter {
private int errors = 0;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -223,7 +222,7 @@ public static void addJavaNature(final IProject project) throws CoreException {
JavaRuntime.getDefaultJREContainerEntry() },
null);

Hashtable<String, String> javaOptions = JavaCore.getOptions();
Map<String, String> javaOptions = JavaCore.getOptions();

IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
if (defaultVMInstall instanceof AbstractVMInstall) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package net.sourceforge.pmd.eclipse.core.ext;

import java.util.LinkedHashSet;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
Expand Down Expand Up @@ -54,12 +55,12 @@ private void processExecutableExtension(IConfigurationElement element) throws Co
if (object instanceof IRuleSetsExtension) {
final IRuleSetsExtension extension = (IRuleSetsExtension) object;

LinkedHashSet<RuleSet> registeredRulesets = new LinkedHashSet<>(ruleSetManager.getRegisteredRuleSets());
Set<RuleSet> registeredRulesets = new LinkedHashSet<>(ruleSetManager.getRegisteredRuleSets());
extension.registerRuleSets(registeredRulesets);
ruleSetManager.getRegisteredRuleSets().clear();
ruleSetManager.getRegisteredRuleSets().addAll(registeredRulesets);

LinkedHashSet<RuleSet> defaultRegisteredRulesets = new LinkedHashSet<>(ruleSetManager.getDefaultRuleSets());
Set<RuleSet> defaultRegisteredRulesets = new LinkedHashSet<>(ruleSetManager.getDefaultRuleSets());
extension.registerDefaultRuleSets(defaultRegisteredRulesets);
ruleSetManager.getDefaultRuleSets().clear();
ruleSetManager.getDefaultRuleSets().addAll(defaultRegisteredRulesets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private enum ChangeType {
ADDED, REMOVED, CHANGED
}

private class ResourceChange {
private final class ResourceChange {
public final ChangeType resourceDeltaType;
public final int flags;
public final IFile file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ private void addFilesTo(IResource resource, Collection<IResource> allKids) {
}
addKids(allKids, kids);
allKids.add(project);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void deconfigure() throws CoreException {
if (pmdBuilderFound(commands)) {
ICommand[] newCommands = new ICommand[commands.length - 1];
for (int i = 0, j = 0; i < commands.length; i++) {
if (!commands[i].getBuilderName().equals(PMDBuilder.PMD_BUILDER)) {
if (!PMDBuilder.PMD_BUILDER.equals(commands[i].getBuilderName())) {
newCommands[j++] = commands[i];
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public static boolean removePMDNature(final IProject project, final IProgressMon
private boolean pmdBuilderFound(ICommand[] commands) {

for (ICommand command : commands) {
if (command.getBuilderName().equals(PMDBuilder.PMD_BUILDER)) {
if (PMDBuilder.PMD_BUILDER.equals(command.getBuilderName())) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ public static void logError(String message, Throwable error) {
* @deprecated we support multiple languages now
*/
public static boolean isJavaFile(IFile file) {
if (file == null) {
return false;
}
return "JAVA".equalsIgnoreCase(file.getFileExtension());
return file != null && "JAVA".equalsIgnoreCase(file.getFileExtension());
}

public static boolean isLanguageFile(IFile file, Language language) {
if (file == null) {
return false;
}
return language.hasExtension(file.getFileExtension());
return file != null && language.hasExtension(file.getFileExtension());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Stack;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.resources.IFile;
Expand Down Expand Up @@ -404,7 +405,7 @@ public static String markerTypeFor(RuleViolation violation) {
private void prepareMarkerAccumulator(IFile file) {
Map<IFile, Set<MarkerInfo2>> accumulator = getAccumulator();
if (accumulator != null) {
accumulator.put(file, new HashSet<MarkerInfo2>());
accumulator.put(file, new HashSet<>());
}
}

Expand Down Expand Up @@ -462,7 +463,7 @@ private List<Review> findReviewedViolations(final IFile file) {
int lineNumber = 0;
boolean findLine = false;
boolean comment = false;
final Stack<String> pendingReviews = new Stack<>();
final Deque<String> pendingReviews = new ArrayDeque<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()))) {
while (reader.ready()) {
String line = reader.readLine();
Expand All @@ -480,7 +481,7 @@ private List<Review> findReviewedViolations(final IFile file) {
findLine = true;
} else if (!comment && findLine && StringUtils.isNotBlank(line) && !line.startsWith("//")) {
findLine = false;
while (!pendingReviews.empty()) {
while (!pendingReviews.isEmpty()) {
// @PMD:REVIEWED:AvoidInstantiatingObjectsInLoops:
// by Herlin on 01/05/05 18:36
final Review review = new Review();
Expand Down Expand Up @@ -547,7 +548,7 @@ private MarkerInfo2 getMarkerInfo(RuleViolation violation, String type) throws P
/**
* Private inner type to handle reviews.
*/
private class Review {
private final class Review {
public String ruleName;
public int lineNumber;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private List<File> findCandidateFiles() throws PropertiesException, CoreExceptio
visitor.setWorkingSet(properties.getProjectWorkingSet());
visitor.setIncludeDerivedFiles(properties.isIncludeDerivedFiles());
visitor.setLanguage(language);
visitor.setFiles(new ArrayList<File>());
visitor.setFiles(new ArrayList<>());
visitProjectResourcesWith(visitor);
return visitor.getFiles();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -30,10 +31,9 @@
*/
public class JobCommandProcessor {
private static final Logger LOG = LoggerFactory.getLogger(JobCommandProcessor.class);
private final Map<AbstractDefaultCommand, Job> jobs = Collections
.synchronizedMap(new HashMap<AbstractDefaultCommand, Job>());
private final Map<AbstractDefaultCommand, Job> jobs = Collections.synchronizedMap(new HashMap<>());

private static ConcurrentLinkedQueue<Job> outstanding = new ConcurrentLinkedQueue<>();
private static Queue<Job> outstanding = new ConcurrentLinkedQueue<>();
private static AtomicInteger count = new AtomicInteger();

private static final JobCommandProcessor INSTANCE = new JobCommandProcessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void add(String name, int value) {
public void addAsMarkerTo(IFile file) throws CoreException {

IMarker marker = file.createMarker(type);
marker.setAttributes(data.keySet().toArray(new String[data.size()]), data.values().toArray());
marker.setAttributes(data.keySet().toArray(new String[0]), data.values().toArray());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ public static RuleSet setFileName(RuleSet ruleSet, String fileName) {

@Deprecated
public static RuleSet addExcludePatterns(RuleSet rs, Collection<String> excludePatterns) {
return addExcludePatterns(rs, excludePatterns, new HashSet<String>());
return addExcludePatterns(rs, excludePatterns, new HashSet<>());
}

@Deprecated
public static RuleSet addIncludePatterns(RuleSet rs, Collection<String> includePatterns) {
return addIncludePatterns(rs, includePatterns, new HashSet<String>());
return addIncludePatterns(rs, includePatterns, new HashSet<>());
}

public static RuleSet clearRules(RuleSet ruleSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public static RuleSet setFileInclusions(RuleSet ruleSet, Collection<Pattern> inc
}

public static RuleSet addFileExclusions(RuleSet rs, Collection<Pattern> excludePatterns) {
return addExcludePatterns(rs, excludePatterns, new HashSet<Pattern>());
return addExcludePatterns(rs, excludePatterns, new HashSet<>());
}

public static RuleSet addFileInclusions(RuleSet rs, Collection<Pattern> includePatterns) {
return addIncludePatterns(rs, includePatterns, new HashSet<Pattern>());
return addIncludePatterns(rs, includePatterns, new HashSet<>());
}

public static RuleSet addExcludePatterns(RuleSet ruleSet, Collection<Pattern> activeExclusionPatterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public NewPropertyDialog(Shell parent, Map<Class<?>, EditorFactory<?>> theEditor

public static Map<Class<?>, EditorFactory<?>> withOnly(Map<Class<?>, EditorFactory<?>> factoriesByType,
Class<?>[] legalTypeKeys) {
Map<Class<?>, EditorFactory<?>> results = new HashMap<Class<?>, EditorFactory<?>>(legalTypeKeys.length);
Map<Class<?>, EditorFactory<?>> results = new HashMap<>(legalTypeKeys.length);

for (Class<?> type : legalTypeKeys) {
if (factoriesByType.containsKey(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,11 @@ private boolean atStringStart(String text, int position) {
}

private boolean atVarnameReference(String text, int position) {
if (syntaxData.varnameReference == null) {
return false;
}
return text.indexOf(syntaxData.varnameReference, position) == position;
return syntaxData.varnameReference != null && text.indexOf(syntaxData.varnameReference, position) == position;
}

private boolean atSingleLineComment(String text, int position) {
if (syntaxData.getComment() == null) {
return false;
}
return text.indexOf(syntaxData.getComment(), position) == position;
return syntaxData.getComment() != null && text.indexOf(syntaxData.getComment(), position) == position;
}

private int getKeywordEnd(String lineText, int start) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,54 @@
*
* @author Brian Remedios
*/
public interface FilterColumnUI {
public final class FilterColumnUI {
private FilterColumnUI() {
// utility / constants class
}

ItemFieldAccessor<String, FilterHolder> INCLUDE_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(null) {
public static final ItemFieldAccessor<String, FilterHolder> INCLUDE_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(
null) {
@Override
public Image imageFor(FilterHolder holder) {
return FilterPreferencesPage.typeIconFor(holder);
}
};

ItemFieldAccessor<String, FilterHolder> PMD_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(Util.COMP_STR) {
public static final ItemFieldAccessor<String, FilterHolder> PMD_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(
Util.COMP_STR) {
@Override
public String valueFor(FilterHolder holder) {
return holder.forPMD ? "Y" : "";
}
};

ItemFieldAccessor<String, FilterHolder> CPD_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(Util.COMP_STR) {
public static final ItemFieldAccessor<String, FilterHolder> CPD_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(
Util.COMP_STR) {
@Override
public String valueFor(FilterHolder holder) {
return holder.forCPD ? "Y" : "";
}
};

ItemFieldAccessor<String, FilterHolder> PATTERN_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(
public static final ItemFieldAccessor<String, FilterHolder> PATTERN_ACCESSOR = new ItemFieldAccessorAdapter<String, FilterHolder>(
Util.COMP_STR) {
@Override
public String valueFor(FilterHolder holder) {
return holder.pattern;
}
};

ItemColumnDescriptor<String, FilterHolder> INCLUDE_DESCRIPTOR = new ItemColumnDescriptor<>("", " Type",
SWT.LEFT, 85, false, INCLUDE_ACCESSOR);
ItemColumnDescriptor<String, FilterHolder> PMD_DESCRIPTOR = new ItemColumnDescriptor<>("", "PMD",
SWT.CENTER, 55, false, PMD_ACCESSOR);
ItemColumnDescriptor<String, FilterHolder> CPD_DESCRIPTOR = new ItemColumnDescriptor<>("", "CPD",
SWT.CENTER, 55, false, CPD_ACCESSOR);
ItemColumnDescriptor<String, FilterHolder> PATTERN_DESCRIPTOR = new ItemColumnDescriptor<>("", "Pattern",
SWT.LEFT, 55, true, PATTERN_ACCESSOR);
public static final ItemColumnDescriptor<String, FilterHolder> INCLUDE_DESCRIPTOR = new ItemColumnDescriptor<>("",
" Type", SWT.LEFT, 85, false, INCLUDE_ACCESSOR);
public static final ItemColumnDescriptor<String, FilterHolder> PMD_DESCRIPTOR = new ItemColumnDescriptor<>("",
"PMD", SWT.CENTER, 55, false, PMD_ACCESSOR);
public static final ItemColumnDescriptor<String, FilterHolder> CPD_DESCRIPTOR = new ItemColumnDescriptor<>("",
"CPD", SWT.CENTER, 55, false, CPD_ACCESSOR);
public static final ItemColumnDescriptor<String, FilterHolder> PATTERN_DESCRIPTOR = new ItemColumnDescriptor<>("",
"Pattern", SWT.LEFT, 55, true, PATTERN_ACCESSOR);

@SuppressWarnings("rawtypes")
ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { INCLUDE_DESCRIPTOR,
public static final ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { INCLUDE_DESCRIPTOR,
// pmd, cpd,
PATTERN_DESCRIPTOR };
}
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private Set<FilterHolder> selectedFilters() {

Set<FilterHolder> holders = new HashSet<>();
for (Object tItem : tableViewer.getTable().getSelection()) {
holders.add((FilterHolder) (((TableItem) tItem).getData()));
holders.add((FilterHolder) ((TableItem) tItem).getData());
}
return holders;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public abstract class AbstractPMDRecord {
* @return an ArrayList with the child-Elements
*/
public List<AbstractPMDRecord> getChildrenAsList() {
return new ArrayList<AbstractPMDRecord>(Arrays.asList(getChildren()));
return new ArrayList<>(Arrays.asList(getChildren()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected final AbstractPMDRecord[] createChildren() {
}
}

children = allMarkerMap.values().toArray(new MarkerRecord[allMarkerMap.size()]);
children = allMarkerMap.values().toArray(new MarkerRecord[0]);
} catch (CoreException e) {
PMDPlugin.getDefault().logError(StringKeys.ERROR_CORE_EXCEPTION + this.toString(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class IconSelector {
private Composite composite;
private ListenerList listeners = new ListenerList();
private ListenerList<IPropertyChangeListener> listeners = new ListenerList<>();
private PriorityDescriptorIcon selectedIcon;

public IconSelector(Composite parent) {
Expand Down Expand Up @@ -72,8 +72,8 @@ public void setSelectedIcon(PriorityDescriptorIcon icon) {
PropertyChangeEvent event = new PropertyChangeEvent(this, "selectedIcon", this.selectedIcon, icon);
this.selectedIcon = icon;

for (Object listener : listeners.getListeners()) {
((IPropertyChangeListener) listener).propertyChange(event);
for (IPropertyChangeListener listener : listeners) {
listener.propertyChange(event);
}
}

Expand Down
Loading