mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Fixed a bunch of code inspection warnings
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -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 : " +
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -150,7 +150,6 @@ public class ContributionsIndexer {
|
||||
}
|
||||
contrib.setInstalled(true);
|
||||
contrib.setInstalledFolder(versionFolder);
|
||||
return;
|
||||
}
|
||||
|
||||
private void syncHardwareWithFilesystem(ContributedPackage pack,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -28,7 +28,6 @@
|
||||
*/
|
||||
package cc.arduino.contributions.packages;
|
||||
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.Platform;
|
||||
|
||||
public abstract class HostDependentDownloadableContribution extends DownloadableContribution {
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user