Fixed a bunch of code inspection warnings

This commit is contained in:
Federico Fissore 2015-03-24 10:54:06 +01:00
parent ed3d467329
commit 24b32422e2
31 changed files with 82 additions and 92 deletions

View File

@ -353,7 +353,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
String sentence = selected.getSentence();
String paragraph = selected.getParagraph();
// String availableVer = selectedLib.getVersion();
String url = selected.getUrl();
// String url = selected.getUrl();
String midcolor = isSelected ? "#000000" : "#888888";
@ -379,8 +379,6 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
} else {
desc += " " + format(_("Version <b>{0}</b>"), installedVer);
}
} else {
// not installed...
}
desc += "</font>";

View File

@ -44,9 +44,9 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
public final static int DESCRIPTION_COL = 0;
public static class ContributedLibraryReleases implements Comparable<ContributedLibraryReleases> {
public String name;
public List<ContributedLibrary> releases = new ArrayList<ContributedLibrary>();
public List<String> versions = new ArrayList<String>();
public final String name;
public final List<ContributedLibrary> releases = new ArrayList<ContributedLibrary>();
public final List<String> versions = new ArrayList<String>();
public ContributedLibrary selected = null;
public ContributedLibraryReleases(ContributedLibrary library) {
@ -122,11 +122,11 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
}
}
private List<ContributedLibraryReleases> contributions = new ArrayList<ContributedLibraryReleases>();
private final List<ContributedLibraryReleases> contributions = new ArrayList<ContributedLibraryReleases>();
private String[] columnNames = {"Description"};
private final String[] columnNames = {"Description"};
private Class<?>[] columnTypes = {ContributedPlatform.class};
private final Class<?>[] columnTypes = {ContributedPlatform.class};
private LibrariesIndexer indexer;

View File

@ -55,18 +55,17 @@ public class LibraryInstaller {
}
}
private LibrariesIndexer indexer;
private File stagingFolder;
private DownloadableContributionsDownloader downloader;
private final LibrariesIndexer indexer;
private final DownloadableContributionsDownloader downloader;
public LibraryInstaller(LibrariesIndexer _indexer) {
indexer = _indexer;
stagingFolder = _indexer.getStagingFolder();
File stagingFolder = _indexer.getStagingFolder();
downloader = new DownloadableContributionsDownloader(stagingFolder) {
@Override
protected void onProgress(Progress progress) {
LibraryInstaller.this.onProgress(progress);
};
}
};
}
@ -160,8 +159,7 @@ public class LibraryInstaller {
rescanLibraryIndex(progress);
}
private void rescanLibraryIndex(MultiStepProgress progress)
throws IOException {
private void rescanLibraryIndex(MultiStepProgress progress) {
progress.setStatus(_("Updating list of installed libraries"));
onProgress(progress);
indexer.rescanLibraries();

View File

@ -61,9 +61,7 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
public boolean shouldContain(ContributedPlatform platform) {
if (platform.getParentPackage() != packager)
return false;
if (!platform.getArchitecture().equals(arch))
return false;
return true;
return platform.getArchitecture().equals(arch);
}
public void add(ContributedPlatform platform) {

View File

@ -1,6 +1,5 @@
package cc.arduino.contributions.ui;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.filters.NoopPredicate;
import cc.arduino.contributions.packages.DownloadableContribution;
import cc.arduino.contributions.ui.DropdownItem;

View File

@ -40,7 +40,7 @@ import javax.swing.event.DocumentListener;
@SuppressWarnings("serial")
public class FilterJTextField extends JTextField {
private String filterHint;
private final String filterHint;
private boolean showingHint;

View File

@ -50,13 +50,13 @@ public abstract class InstallerJDialog<T> extends JDialog {
// Toolbar on top of the window:
// - Categories drop-down menu
protected JLabel categoryLabel;
protected JComboBox categoryChooser;
protected Component categoryStrut1;
protected Component categoryStrut2;
protected Component categoryStrut3;
protected final JLabel categoryLabel;
protected final JComboBox categoryChooser;
protected final Component categoryStrut1;
protected final Component categoryStrut2;
protected final Component categoryStrut3;
// - Search text-field
protected FilterJTextField filterField;
protected final FilterJTextField filterField;
// Currently selected category and filters
protected Predicate<T> categoryFilter;
protected String[] filters;
@ -75,9 +75,9 @@ public abstract class InstallerJDialog<T> extends JDialog {
// Bottom:
// - Progress bar
protected ProgressJProgressBar progressBar;
protected Box progressBox;
protected Box errorMessageBox;
protected final ProgressJProgressBar progressBar;
protected final Box progressBox;
protected final Box errorMessageBox;
private final JLabel errorMessage;
public InstallerJDialog(Frame parent, String title, ModalityType applicationModal, String noConnectionErrorMessage) {
@ -136,7 +136,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
@Override
public void keyReleased(KeyEvent keyEvent) {
if (keyEvent.getKeyCode() != keyEvent.VK_DOWN && keyEvent.getKeyCode() != KeyEvent.VK_UP) {
if (keyEvent.getKeyCode() != KeyEvent.VK_DOWN && keyEvent.getKeyCode() != KeyEvent.VK_UP) {
return;
}
@ -263,7 +263,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
}
}
protected ActionListener categoryChooserActionListener = new ActionListener() {
protected final ActionListener categoryChooserActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {

View File

@ -42,7 +42,7 @@ import static processing.app.I18n._;
public class AStyle implements Tool {
private static String FORMATTER_CONF = "formatter.conf";
private static final String FORMATTER_CONF = "formatter.conf";
private final AStyleInterface aStyleInterface;
private final String formatterConfiguration;

View File

@ -48,10 +48,7 @@ public class Event extends ActionEvent {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append("\n").append(payload.toString());
return sb.toString();
return super.toString() + "\n" + payload.toString();
}
}

View File

@ -38,7 +38,7 @@ import java.util.Map;
public class SplashScreenHelper {
private final Map desktopHints;
private SplashScreen splash;
private final SplashScreen splash;
private Rectangle2D.Double splashTextArea;
private Graphics2D splashGraphics;

View File

@ -154,12 +154,12 @@ public abstract class ContributedLibrary extends DownloadableContribution {
String thisVersion = getVersion();
String otherVersion = ((ContributedLibrary) obj).getVersion();
boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion == otherVersion || thisVersion.equals(otherVersion);
boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion.equals(otherVersion);
String thisName = getName();
String otherName = ((ContributedLibrary) obj).getName();
boolean nameEquals = thisName == null || otherName == null || thisName == otherName || thisName.equals(otherName);
boolean nameEquals = thisName == null || otherName == null || thisName.equals(otherName);
return versionEquals && nameEquals;
}

View File

@ -51,10 +51,10 @@ import com.fasterxml.jackson.module.mrbean.MrBeanModule;
public class LibrariesIndexer {
private LibrariesIndex index;
private LibraryList installedLibraries = new LibraryList();
private final LibraryList installedLibraries = new LibraryList();
private List<File> librariesFolders;
private File indexFile;
private File stagingFolder;
private final File indexFile;
private final File stagingFolder;
private File sketchbookLibrariesFolder;
public LibrariesIndexer(File preferencesFolder) {
@ -84,13 +84,12 @@ public class LibrariesIndexer {
}
}
public void setLibrariesFolders(List<File> _librariesFolders)
throws IOException {
public void setLibrariesFolders(List<File> _librariesFolders) {
librariesFolders = _librariesFolders;
rescanLibraries();
}
public void rescanLibraries() throws IOException {
public void rescanLibraries() {
// Clear all installed flags
installedLibraries.clear();
for (ContributedLibrary lib : index.getLibraries())

View File

@ -94,7 +94,7 @@ public abstract class ContributedPackage {
for (ContributedPlatform plat : getPlatforms()) {
res += "\n Plaform : name : " + plat.getName();
if (plat.isInstalled()) {
res += "\n " + ((DownloadableContribution) plat);
res += "\n " + plat;
}
res += "\n category : " + plat.getCategory();
res += "\n architecture : " +

View File

@ -60,12 +60,13 @@ public abstract class ContributedPlatform extends DownloadableContribution {
return new LinkedList<ContributedTool>(resolvedTools);
}
public List<ContributedTool> resolveToolsDependencies(Collection<ContributedPackage> packages) {
public void resolveToolsDependencies(Collection<ContributedPackage> packages) {
resolvedTools = new ArrayList<ContributedTool>();
// If there are no dependencies return empty list
if (getToolsDependencies() == null)
return resolvedTools;
if (getToolsDependencies() == null) {
return;
}
// For each tool dependency
for (ContributedToolReference dep : getToolsDependencies()) {
@ -76,7 +77,6 @@ public abstract class ContributedPlatform extends DownloadableContribution {
}
resolvedTools.add(tool);
}
return resolvedTools;
}
public ContributedPackage getParentPackage() {

View File

@ -37,8 +37,8 @@ import processing.app.debug.TargetPlatform;
public class ContributedTargetPackage implements TargetPackage {
private String id;
private Map<String, TargetPlatform> platforms;
private final String id;
private final Map<String, TargetPlatform> platforms;
public ContributedTargetPackage(String _id) {
id = _id;

View File

@ -65,12 +65,11 @@ public class ContributionInstaller {
}
}
private File stagingFolder;
private ContributionsIndexer indexer;
private DownloadableContributionsDownloader downloader;
private final ContributionsIndexer indexer;
private final DownloadableContributionsDownloader downloader;
public ContributionInstaller(ContributionsIndexer contributionsIndexer) {
stagingFolder = contributionsIndexer.getStagingFolder();
File stagingFolder = contributionsIndexer.getStagingFolder();
indexer = contributionsIndexer;
downloader = new DownloadableContributionsDownloader(stagingFolder) {
@Override

View File

@ -51,7 +51,7 @@ public abstract class ContributionsIndex {
return pack.findTool(name, version);
}
private List<String> categories = new ArrayList<String>();
private final List<String> categories = new ArrayList<String>();
public List<String> getCategories() {
return categories;

View File

@ -150,7 +150,6 @@ public class ContributionsIndexer {
}
contrib.setInstalled(true);
contrib.setInstalledFolder(versionFolder);
return;
}
private void syncHardwareWithFilesystem(ContributedPackage pack,

View File

@ -80,14 +80,9 @@ public abstract class DownloadableContribution {
@Override
public String toString() {
String chk = getChecksum();
if (chk.length() > 14)
chk = getChecksum().substring(0, 14);
String res = "";
// res += getUrl() + " (" + chk + ") ";
if (installed) {
res += "installed on " + installedFolder.getAbsolutePath() + " (" +
getSize() + " bytes)";
res += "installed on " + installedFolder.getAbsolutePath() + " (" + getSize() + " bytes)";
}
return res;
}

View File

@ -42,7 +42,7 @@ import static processing.app.I18n.format;
public class DownloadableContributionsDownloader {
private File stagingFolder;
private final File stagingFolder;
public DownloadableContributionsDownloader(File _stagingFolder) {
stagingFolder = _stagingFolder;

View File

@ -28,7 +28,6 @@
*/
package cc.arduino.contributions.packages;
import processing.app.BaseNoGui;
import processing.app.Platform;
public abstract class HostDependentDownloadableContribution extends DownloadableContribution {

View File

@ -33,7 +33,7 @@ import java.io.IOException;
public class LinuxFileNativeUtils {
public static LibCNative libc = LibCNative.libc;
public static final LibCNative libc = LibCNative.libc;
public static void chmod(File file, int mode) throws IOException {
int res = libc.chmod(file.getAbsolutePath(), mode);

View File

@ -29,11 +29,10 @@
package cc.arduino.os.windows;
import java.io.File;
import java.io.IOException;
public class WindowsFileNativeUtils {
public static void chmod(File file, int mode) throws IOException {
public static void chmod(File file, int mode) {
// Empty
}

View File

@ -36,8 +36,9 @@ import processing.app.debug.TargetBoard;
public class UploaderFactory {
public Uploader newUploader(TargetBoard board, BoardPort port, boolean noUploadPort) {
if (noUploadPort)
return new SerialUploader(noUploadPort);
if (noUploadPort) {
return new SerialUploader(true);
}
if ("true".equals(board.getPreferences().get("upload.via_ssh")) && port != null && "network".equals(port.getProtocol())) {
return new SSHUploader(port);

View File

@ -58,8 +58,7 @@ public class ClearSignedVerifier {
* @throws FileNotFoundException
*/
public static VerifyResult verify(File signedTextFile,
PGPPublicKeyRingCollection pubKeyRing)
throws FileNotFoundException {
PGPPublicKeyRingCollection pubKeyRing) {
// Create the result object
VerifyResult result = new VerifyResult();
result.clearText = null;

View File

@ -119,7 +119,10 @@ public class SSHUploader extends Uploader {
private boolean runAVRDude(SSH ssh) throws IOException, JSchException {
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences());
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
if (boardPreferences != null) {
prefs.putAll(boardPreferences);
}
prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool")));
String additionalParams = verbose ? prefs.get("upload.params.verbose") : prefs.get("upload.params.quiet");

View File

@ -60,7 +60,10 @@ public class SerialUploader extends Uploader {
// FIXME: Preferences should be reorganized
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences());
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
if (boardPreferences != null) {
prefs.putAll(boardPreferences);
}
String tool = prefs.getOrExcept("upload.tool");
if (tool.contains(":")) {
String[] split = tool.split(":", 2);
@ -242,7 +245,10 @@ public class SerialUploader extends Uploader {
}
PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences());
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
if (boardPreferences != null) {
prefs.putAll(boardPreferences);
}
PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer);
if (programmerPrefs == null)
throw new RunnerException(
@ -295,7 +301,10 @@ public class SerialUploader extends Uploader {
// Build configuration for the current programmer
PreferencesMap prefs = PreferencesData.getMap();
prefs.putAll(BaseNoGui.getBoardPreferences());
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
if (boardPreferences != null) {
prefs.putAll(boardPreferences);
}
prefs.putAll(programmerPrefs);
// Create configuration for bootloader tool

View File

@ -30,10 +30,10 @@ package cc.arduino.utils;
public class MultiStepProgress implements Progress {
double steps;
private final double steps;
double step;
double stepProgress;
private double step;
private double stepProgress;
String status;

View File

@ -30,11 +30,11 @@ package cc.arduino.utils;
public interface Progress {
public void setProgress(double progress);
void setProgress(double progress);
double getProgress();
public void setStatus(String _status);
void setStatus(String _status);
String getStatus();

View File

@ -55,9 +55,9 @@ public class FileDownloader extends Observable {
private long initialSize;
private Long downloadSize = null;
private long downloaded;
private URL downloadUrl;
private final URL downloadUrl;
private File outputFile;
private final File outputFile;
private InputStream stream = null;
private Exception error;
@ -225,6 +225,7 @@ public class FileDownloader extends Observable {
try {
file.close();
} catch (Exception e) {
//ignore
}
}
@ -233,6 +234,7 @@ public class FileDownloader extends Observable {
try {
stream.close();
} catch (Exception e) {
//ignore
}
}
}

View File

@ -757,13 +757,9 @@ public class BaseNoGui {
// Scan for libraries in each library folder.
// Libraries located in the latest folders on the list can override
// other libraries with the same name.
try {
BaseNoGui.librariesIndexer.setSketchbookLibrariesFolder(getSketchbookLibrariesFolder());
BaseNoGui.librariesIndexer.setLibrariesFolders(librariesFolders);
BaseNoGui.librariesIndexer.rescanLibraries();
} catch (IOException e) {
showWarning(_("Error"), _("Error loading libraries"), e);
}
BaseNoGui.librariesIndexer.setSketchbookLibrariesFolder(getSketchbookLibrariesFolder());
BaseNoGui.librariesIndexer.setLibrariesFolders(librariesFolders);
BaseNoGui.librariesIndexer.rescanLibraries();
populateImportToLibraryTable();
}