Skip to content

Commit fd1f209

Browse files
committed
Merge pull request #417 from DevFactory/release/multiple-code-improvements-fix-5
multiple code improvements: squid:S1118, squid:S1197, squid:UselessParenthesesCheck, squid:CommentedOutCodeLine, squid:S2864
2 parents 7c43935 + 014deb1 commit fd1f209

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/managers/ArduinoPlatform.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ public Properties getPlatformProperties() throws CoreException {
145145
this.platformProperties = new Properties();
146146
try (BufferedReader reader = new BufferedReader(new FileReader(getPlatformFile()))) {
147147
// There are regex's here and need to preserve the \'s
148-
StringBuffer buffer = new StringBuffer();
148+
StringBuilder builder = new StringBuilder();
149149
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
150-
buffer.append(line.replace("\\", "\\\\")); //$NON-NLS-1$ //$NON-NLS-2$
151-
buffer.append('\n');
150+
builder.append(line.replace("\\", "\\\\")); //$NON-NLS-1$ //$NON-NLS-2$
151+
builder.append('\n');
152152
}
153-
try (Reader reader1 = new StringReader(buffer.toString())) {
153+
try (Reader reader1 = new StringReader(builder.toString())) {
154154
this.platformProperties.load(reader1);
155155
}
156156
} catch (IOException e) {

it.baeyens.arduino.core/src/it/baeyens/arduino/managers/Manager.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public class Manager {
6464
static private List<PackageIndex> packageIndices;
6565
static private LibraryIndex libraryIndex;
6666

67+
private Manager() {}
68+
6769
private static void internalLoadIndices() {
6870
String[] boardUrls = ConfigurationPreferences.getBoardURLList();
6971
packageIndices = new ArrayList<>(boardUrls.length);
@@ -100,7 +102,7 @@ public static void startup_Pluging(IProgressMonitor monitor) {
100102
if (pkg != null) {
101103
ArduinoPlatform platform = pkg.getLatestPlatform(platformName);
102104
if (platform == null) {
103-
ArduinoPlatform platformList[] = new ArduinoPlatform[pkg.getLatestPlatforms().size()];
105+
ArduinoPlatform[] platformList = new ArduinoPlatform[pkg.getLatestPlatforms().size()];
104106
pkg.getLatestPlatforms().toArray(platformList);
105107
platform = platformList[0];
106108
}
@@ -169,7 +171,6 @@ static public IStatus downloadAndInstall(ArduinoPlatform platform, boolean force
169171
}
170172
}
171173

172-
// mstatus.add(make_eclipse_plugin_txt_file(platform));
173174
return mstatus.getChildren().length == 0 ? Status.OK_STATUS : mstatus;
174175

175176
}
@@ -327,8 +328,8 @@ public static List<ArduinoPlatform> getPlatforms() {
327328
return platforms;
328329
}
329330

330-
public static ArduinoPlatform getPlatform(String PlatformTxt) {
331-
String searchString = new File(PlatformTxt).toString();
331+
public static ArduinoPlatform getPlatform(String platformTxt) {
332+
String searchString = new File(platformTxt).toString();
332333
for (PackageIndex index : packageIndices) {
333334
for (Package pkg : index.getPackages()) {
334335
for (ArduinoPlatform curPlatform : pkg.getPlatforms()) {
@@ -627,8 +628,8 @@ public static IStatus extract(ArchiveInputStream in, File destFolder, int stripP
627628
}
628629

629630
// Set folders timestamps
630-
for (File folder : foldersTimestamps.keySet()) {
631-
folder.setLastModified(foldersTimestamps.get(folder).longValue());
631+
for (Map.Entry<File, Long> entry : foldersTimestamps.entrySet()) {
632+
entry.getKey().setLastModified(entry.getValue().longValue());
632633
}
633634

634635
return Status.OK_STATUS;
@@ -672,7 +673,7 @@ private static void copyStreamToFile(InputStream in, long size, File outputFile)
672673

673674
// if size is not available, copy until EOF...
674675
if (size == -1) {
675-
byte buffer[] = new byte[4096];
676+
byte[] buffer = new byte[4096];
676677
int length;
677678
while ((length = in.read(buffer)) != -1) {
678679
fos.write(buffer, 0, length);
@@ -681,7 +682,7 @@ private static void copyStreamToFile(InputStream in, long size, File outputFile)
681682
}
682683

683684
// ...else copy just the needed amount of bytes
684-
byte buffer[] = new byte[4096];
685+
byte[] buffer = new byte[4096];
685686
long leftToWrite = size;
686687
while (leftToWrite > 0) {
687688
int length = in.read(buffer);

0 commit comments

Comments
 (0)