Various bugfixes as identified by other analysis tools
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7607 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
adedb883db
commit
6c7c4d6bc9
@ -46,6 +46,7 @@ public class FileChangeReviewer implements IResourceChangeListener {
|
||||
public int hashCode() { return resourceDeltaType.hashCode() + 13 + file.hashCode() + flags; }
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) return false;
|
||||
if (other == this) return true;
|
||||
if (other.getClass() == getClass()) {
|
||||
ResourceChange chg = (ResourceChange)other;
|
||||
|
@ -518,15 +518,7 @@ public class PMDPlugin extends AbstractUIPlugin {
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (IResource irc : kids) {
|
||||
if (irc instanceof IFile) {
|
||||
allKids.add(irc);
|
||||
continue;
|
||||
}
|
||||
if (irc instanceof IFolder) {
|
||||
addFilesTo(irc, allKids);
|
||||
}
|
||||
}
|
||||
addKids(allKids, kids);
|
||||
|
||||
allKids.add(folder);
|
||||
return;
|
||||
@ -540,19 +532,26 @@ public class PMDPlugin extends AbstractUIPlugin {
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (IResource irc : kids) {
|
||||
if (irc instanceof IFile) {
|
||||
allKids.add(irc);
|
||||
continue;
|
||||
}
|
||||
if (irc instanceof IFolder) {
|
||||
addFilesTo(irc, allKids);
|
||||
}
|
||||
}
|
||||
addKids(allKids, kids);
|
||||
allKids.add(project);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void addKids(Collection<IResource> allKids, IResource[] kids) {
|
||||
|
||||
if (kids == null) return;
|
||||
|
||||
for (IResource irc : kids) {
|
||||
if (irc instanceof IFile) {
|
||||
allKids.add(irc);
|
||||
continue;
|
||||
}
|
||||
if (irc instanceof IFolder) {
|
||||
addFilesTo(irc, allKids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removedMarkersIn(IResource resource) {
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class MarkerUtil {
|
||||
} catch (CoreException ex) {
|
||||
// what do to?
|
||||
}
|
||||
if (ruleMarkers.length > 0) {
|
||||
if (ruleMarkers != null && ruleMarkers.length > 0) {
|
||||
foundOne[0] = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -165,11 +165,11 @@ public class ProjectPropertiesImpl implements IProjectProperties {
|
||||
* @see net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties#setRuleSetFile(String)
|
||||
*/
|
||||
public void setRuleSetFile(String ruleSetFile) throws PropertiesException {
|
||||
log.debug("Set rule set file for project " + this.project.getName() + ": " + ruleSetFile);
|
||||
this.needRebuild |= this.ruleSetFile == null || !ruleSetFile.equals(ruleSetFile);
|
||||
log.debug("Set rule set file for project " + project.getName() + ": " + ruleSetFile);
|
||||
needRebuild |= this.ruleSetFile == null || !this.ruleSetFile.equals(ruleSetFile);
|
||||
this.ruleSetFile = ruleSetFile;
|
||||
if (this.ruleSetStoredInProject && !isRuleSetFileExist()) {
|
||||
throw new PropertiesException("The project ruleset file cannot be found for project " + this.project.getName()); // TODO NLS
|
||||
if (ruleSetStoredInProject && !isRuleSetFileExist()) {
|
||||
throw new PropertiesException("The project ruleset file cannot be found for project " + project.getName()); // TODO NLS
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ public class ShapeDescriptor implements Cloneable {
|
||||
|
||||
public boolean equals(Object other) {
|
||||
|
||||
if (other == null) return false;
|
||||
if (this == other) return true;
|
||||
if (other.getClass() != getClass()) return false;
|
||||
|
||||
|
@ -155,7 +155,7 @@ public class ShapePicker<T extends Object> extends Canvas implements ISelectionP
|
||||
|
||||
switch (SWT.LEFT) { // TODO take from style bits
|
||||
case SWT.CENTER: xOffset = (width / 2) - (itemWidth / 2) - xBoundary + step; break;
|
||||
case SWT.RIGHT: xOffset = width - width - xBoundary; break;
|
||||
case SWT.RIGHT: xOffset = 0 - xBoundary; break;
|
||||
case SWT.LEFT: xOffset = xBoundary + step;
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ public class ShapePicker<T extends Object> extends Canvas implements ISelectionP
|
||||
|
||||
switch (SWT.LEFT) { // TODO take from style bits
|
||||
case SWT.CENTER: xOffset = (width / 2) - (itemWidth / 2) - xBoundary + step; break;
|
||||
case SWT.RIGHT: xOffset = width - width - xBoundary; break;
|
||||
case SWT.RIGHT: xOffset = 0 - xBoundary; break;
|
||||
case SWT.LEFT: xOffset = xBoundary + step;
|
||||
}
|
||||
|
||||
|
@ -256,6 +256,7 @@ public class ClearReviewsAction extends AbstractUIAction implements IResourceVis
|
||||
while (reader.ready()) {
|
||||
String origLine = reader.readLine();
|
||||
String line = origLine.trim();
|
||||
if (line == null) break;
|
||||
int index = origLine.indexOf(PMDRuntimeConstants.PMD_STYLE_REVIEW_COMMENT);
|
||||
int quoteIndex = origLine.indexOf('"');
|
||||
|
||||
|
@ -728,7 +728,9 @@ System.out.println("updating icons");
|
||||
}
|
||||
|
||||
if (checkCodeOnSave != null) {
|
||||
preferences.isCheckAfterSaveEnabled(checkCodeOnSave.getSelection());
|
||||
boolean doCheck = checkCodeOnSave.getSelection();
|
||||
preferences.isCheckAfterSaveEnabled(doCheck);
|
||||
PMDPlugin.getDefault().fileChangeListenerEnabled(doCheck);
|
||||
}
|
||||
|
||||
if (useCustomPriorityNames != null) {
|
||||
@ -757,7 +759,6 @@ System.out.println("updating icons");
|
||||
|
||||
preferences.sync();
|
||||
|
||||
PMDPlugin.getDefault().fileChangeListenerEnabled(checkCodeOnSave.getSelection());
|
||||
PMDPlugin.getDefault().applyLogPreferences(preferences);
|
||||
|
||||
return true;
|
||||
|
@ -187,9 +187,8 @@ public class PerRulePropertyPanelManager extends AbstractRulePanelManager implem
|
||||
return warnings;
|
||||
}
|
||||
|
||||
warnings.add("Unreferences variables: " + unreferencedVariables.toArray(new String[unreferencedVariables.size()]));
|
||||
|
||||
|
||||
warnings.add("Unreferences variables: " + unreferencedVariables);
|
||||
|
||||
return warnings;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class PriorityDescriptor implements Cloneable {
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
|
||||
if (other == null) return false;
|
||||
if (this == other) return true;
|
||||
if (other.getClass() != getClass()) return false;
|
||||
|
||||
|
@ -153,8 +153,8 @@ public class ViewMemento {
|
||||
contentReader = new BufferedReader(new FileReader(file));
|
||||
|
||||
while (contentReader.ready()) {
|
||||
final String line = contentReader.readLine();
|
||||
if (line.length() != 0) {
|
||||
String line = contentReader.readLine();
|
||||
if (line != null && line.length() != 0) {
|
||||
// the first Line of Text has to be the XML-Prefix
|
||||
isXmlFile = XML_PREFIX.equalsIgnoreCase(line);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user