Fixing squid:S1066 - Collapsible "if" statements should be merged.

This commit is contained in:
Faisal Hameed
2016-04-19 18:27:48 +05:00
parent 42eac2d71d
commit ef9358023f
6 changed files with 20 additions and 38 deletions
@@ -141,10 +141,8 @@ public class Resource
*/ */
public void clearMarker () public void clearMarker ()
{ {
if (_marker.exists()) { if (_marker.exists() && !_marker.delete()) {
if (!_marker.delete()) { log.warning("Failed to erase marker file '" + _marker + "'.");
log.warning("Failed to erase marker file '" + _marker + "'.");
}
} }
} }
@@ -178,10 +176,8 @@ public class Resource
public void erase () public void erase ()
{ {
clearMarker(); clearMarker();
if (_local.exists()) { if (_local.exists() && !_local.delete()) {
if (!_local.delete()) { log.warning("Failed to erase resource '" + _local + "'.");
log.warning("Failed to erase resource '" + _local + "'.");
}
} }
} }
@@ -343,10 +343,8 @@ public class GetdownAppletConfig
protected void ensureAppdirExists () throws Exception protected void ensureAppdirExists () throws Exception
{ {
// if our application directory does not exist, auto-create it // if our application directory does not exist, auto-create it
if (!appdir.exists() || !appdir.isDirectory()) { if ((!appdir.exists() || !appdir.isDirectory()) && !appdir.mkdirs()) {
if (!appdir.mkdirs()) { throw new Exception("m.create_appdir_failed");
throw new Exception("m.create_appdir_failed");
}
} }
} }
@@ -113,10 +113,8 @@ public abstract class Downloader extends Thread
// finally report our download completion if we did not already do so when downloading // finally report our download completion if we did not already do so when downloading
// our final resource // our final resource
if (_obs != null && !_complete) { if (_obs != null && !_complete && !_obs.downloadProgress(100, 0)) {
if (!_obs.downloadProgress(100, 0)) { return false;
return false;
}
} }
} catch (DownloadAbortedException e) { } catch (DownloadAbortedException e) {
@@ -154,11 +152,9 @@ public abstract class Downloader extends Thread
{ {
// make sure the resource's target directory exists // make sure the resource's target directory exists
File parent = new File(rsrc.getLocal().getParent()); File parent = new File(rsrc.getLocal().getParent());
if (!parent.exists()) { if (!parent.exists() && !parent.mkdirs()) {
if (!parent.mkdirs()) { log.warning("Failed to create target directory for resource '" + rsrc + "'. " +
log.warning("Failed to create target directory for resource '" + rsrc + "'. " + "Download will certainly fail.");
"Download will certainly fail.");
}
} }
doDownload(rsrc); doDownload(rsrc);
} }
@@ -64,11 +64,9 @@ public class DigesterTask extends Task
} }
// make sure _storepass and _keyalias are set, if _storepath is set // make sure _storepass and _keyalias are set, if _storepath is set
if (_storepath != null) { if (_storepath != null && (_storepass == null || _storealias == null)) {
if (_storepass == null || _storealias == null) { throw new BuildException(
throw new BuildException(
"Must specify both a keystore password and a private key alias."); "Must specify both a keystore password and a private key alias.");
}
} }
try { try {
@@ -106,10 +106,8 @@ public class Patcher
// make sure the file's parent directory exists // make sure the file's parent directory exists
File pdir = target.getParentFile(); File pdir = target.getParentFile();
if (!pdir.exists()) { if (!pdir.exists() && !pdir.mkdirs()) {
if (!pdir.mkdirs()) { log.warning("Failed to create parent for '" + target + "'.");
log.warning("Failed to create parent for '" + target + "'.");
}
} }
InputStream in = null; InputStream in = null;
@@ -38,17 +38,13 @@ public class FileUtil extends com.samskivert.util.FileUtil
// place and then delete the old file // place and then delete the old file
if (dest.exists()) { if (dest.exists()) {
File temp = new File(dest.getPath() + "_old"); File temp = new File(dest.getPath() + "_old");
if (temp.exists()) { if (temp.exists() && !temp.delete()) {
if (!temp.delete()) { log.warning("Failed to delete old intermediate file " + temp + ".");
log.warning("Failed to delete old intermediate file " + temp + "."); // the subsequent code will probably fail
// the subsequent code will probably fail
}
} }
if (dest.renameTo(temp)) { if (dest.renameTo(temp)) {
if (source.renameTo(dest)) { if (source.renameTo(dest) && !temp.delete()) {
if (!temp.delete()) { log.warning("Failed to delete intermediate file " + temp + ".");
log.warning("Failed to delete intermediate file " + temp + ".");
}
return true; return true;
} }
} }