Skip to content
Permalink
Browse files
No need to nest in else.
  • Loading branch information
garydgregory committed Mar 5, 2021
1 parent 02ff1ee commit 7b7f61c3b99f0bb9827ad4c361421f8df1d9591b
Showing 20 changed files with 100 additions and 70 deletions.
@@ -58,7 +58,8 @@ public static FileSystemException generate(final DavException davExc, final DavM
final Object o = excConstr.newInstance(msg);
if (o instanceof FileSystemException) {
return (FileSystemException) o;
} else if (o instanceof Exception) {
}
if (o instanceof Exception) {
return new FileSystemException(msg, (Exception) o);
}
}
@@ -52,7 +52,8 @@ public static FileSystemException generate(final DavException davExc) throws Fil
final Object o = excConstr.newInstance(msg);
if (o instanceof FileSystemException) {
return (FileSystemException) o;
} else if (o instanceof Exception) {
}
if (o instanceof Exception) {
return new FileSystemException(msg, (Exception) o);
}
}
@@ -116,9 +116,11 @@ private SmbFile createSmbFile(final FileName fileName)
protected FileType doGetType() throws Exception {
if (!file.exists()) {
return FileType.IMAGINARY;
} else if (file.isDirectory()) {
}
if (file.isDirectory()) {
return FileType.FOLDER;
} else if (file.isFile()) {
}
if (file.isFile()) {
return FileType.FILE;
}

@@ -194,7 +196,8 @@ protected InputStream doGetInputStream(final int bufferSize) throws Exception {
} catch (final SmbException e) {
if (e.getNtStatus() == NtStatus.NT_STATUS_NO_SUCH_FILE) {
throw new org.apache.commons.vfs2.FileNotFoundException(getName());
} else if (file.isDirectory()) {
}
if (file.isDirectory()) {
throw new FileTypeHasNoContentException(getName());
}

@@ -35,9 +35,8 @@ public class SmbProviderTestCase extends AbstractProviderTestConfig implements P
public static Test suite() throws Exception {
if (System.getProperty(TEST_URI) != null) {
return new ProviderTestSuite(new SmbProviderTestCase());
} else {
return notConfigured(SmbProviderTestCase.class);
}
return notConfigured(SmbProviderTestCase.class);
}

/**
@@ -120,18 +120,17 @@ public int compareTo(final StaticUserAuthenticator other) {
}

private int compareStringOrNull(final String thisString, final String otherString) {
if (thisString == null) {
if (otherString != null) {
return -1;
}
} else {
if (thisString != null) {
if (otherString == null) {
return 1;
}

final int result = thisString.compareTo(otherString);
return result;
}
if (otherString != null) {
return -1;
}

return 0;
}
@@ -235,7 +235,7 @@ public long getDelay() {
* @param delay The delay period.
*/
public void setDelay(final long delay) {
this.delay = delay > 0 ? delay : DEFAULT_DELAY;
this.delay = delay > 0 ? delay : DEFAULT_DELAY;
}

/**
@@ -191,7 +191,8 @@ public FileName getParent() {
if (idx == -1 || idx == getPath().length() - 1) {
// No parent
return null;
} else if (idx == 0) {
}
if (idx == 0) {
// Root is the parent
parentPath = SEPARATOR;
} else {
@@ -305,7 +306,8 @@ public String getRelativeName(final FileName name) throws FileSystemException {
// Deal with root
if (basePathLen == 1 && pathLen == 1) {
return ".";
} else if (basePathLen == 1) {
}
if (basePathLen == 1) {
return path.substring(1);
}

@@ -317,7 +319,8 @@ public String getRelativeName(final FileName name) throws FileSystemException {
if (pos == basePathLen && pos == pathLen) {
// Same names
return ".";
} else if (pos == basePathLen && pos < pathLen && path.charAt(pos) == SEPARATOR_CHAR) {
}
if (pos == basePathLen && pos < pathLen && path.charAt(pos) == SEPARATOR_CHAR) {
// A descendent of the base path
return path.substring(pos + 1);
}
@@ -513,11 +516,14 @@ public static boolean checkName(final String basePath, final String path, final
if (scope == NameScope.CHILD) {
return path.length() != baseLen && (baseLen <= 1 || path.charAt(baseLen) == SEPARATOR_CHAR)
&& path.indexOf(SEPARATOR_CHAR, baseLen + 1) == -1;
} else if (scope == NameScope.DESCENDENT) {
}
if (scope == NameScope.DESCENDENT) {
return path.length() != baseLen && (baseLen <= 1 || path.charAt(baseLen) == SEPARATOR_CHAR);
} else if (scope == NameScope.DESCENDENT_OR_SELF) {
}
if (scope == NameScope.DESCENDENT_OR_SELF) {
return baseLen <= 1 || path.length() <= baseLen || path.charAt(baseLen) == SEPARATOR_CHAR;
} else if (scope != NameScope.FILE_SYSTEM) {
}
if (scope != NameScope.FILE_SYSTEM) {
throw new IllegalArgumentException();
}

@@ -1104,7 +1104,8 @@ public FileObject[] getChildren() throws FileSystemException {
// honor the new doListChildren contract
// return null;
throw new FileNotFolderException(fileName);
} else if (files.length == 0) {
}
if (files.length == 0) {
// No children
children = FileName.EMPTY_ARRAY;
} else {
@@ -123,11 +123,11 @@ private void maybeTypeChanged(final FileType oldType) throws Exception {
protected FileType doGetType() throws FileSystemException {
if (file != null) {
return file.getType();
} else if (children.isEmpty()) {
}
if (children.isEmpty()) {
return FileType.IMAGINARY;
} else {
return FileType.FOLDER;
}
return FileType.FOLDER;
}

/**
@@ -369,11 +369,14 @@ protected FileType doGetType() throws Exception {

if (this.ftpFile == UNKNOWN) {
return FileType.IMAGINARY;
} else if (this.ftpFile.isDirectory()) {
}
if (this.ftpFile.isDirectory()) {
return FileType.FOLDER;
} else if (this.ftpFile.isFile()) {
}
if (this.ftpFile.isFile()) {
return FileType.FILE;
} else if (this.ftpFile.isSymbolicLink()) {
}
if (this.ftpFile.isSymbolicLink()) {
final FileObject linkDest = getLinkDestination();
// VFS-437: We need to check if the symbolic link links back to the symbolic link itself
if (this.isCircular(linkDest)) {
@@ -169,11 +169,11 @@ protected FileType doGetType() throws Exception {
if (status == HttpURLConnection.HTTP_OK
|| status == HttpURLConnection.HTTP_BAD_METHOD /* method is bad, but resource exist */) {
return FileType.FILE;
} else if (status == HttpURLConnection.HTTP_NOT_FOUND || status == HttpURLConnection.HTTP_GONE) {
}
if (status == HttpURLConnection.HTTP_NOT_FOUND || status == HttpURLConnection.HTTP_GONE) {
return FileType.IMAGINARY;
} else {
throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status));
}
throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status));
}

@Override
@@ -159,11 +159,11 @@ protected FileType doGetType() throws Exception {
if (status == HttpStatus.SC_OK
|| status == HttpStatus.SC_METHOD_NOT_ALLOWED /* method is not allowed, but resource exist */) {
return FileType.FILE;
} else if (status == HttpStatus.SC_NOT_FOUND || status == HttpStatus.SC_GONE) {
}
if (status == HttpStatus.SC_NOT_FOUND || status == HttpStatus.SC_GONE) {
return FileType.IMAGINARY;
} else {
throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status));
}
throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status));
}

@Override
@@ -160,11 +160,11 @@ protected FileType doGetType() throws Exception {
if (status == HttpStatus.SC_OK
|| status == HttpStatus.SC_METHOD_NOT_ALLOWED /* method is not allowed, but resource exist */) {
return FileType.FILE;
} else if (status == HttpStatus.SC_NOT_FOUND || status == HttpStatus.SC_GONE) {
}
if (status == HttpStatus.SC_NOT_FOUND || status == HttpStatus.SC_GONE) {
return FileType.IMAGINARY;
} else {
throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status));
}
throw new FileSystemException("vfs.provider.http/head.error", getName(), Integer.valueOf(status));
}

@Override
@@ -104,41 +104,56 @@ Object getAttribute(final Name attrName) throws FileSystemException {
Name lookupName(final String attrName) {
if (Name.CLASS_PATH.toString().equals(attrName)) {
return Name.CLASS_PATH;
} else if (Name.CONTENT_TYPE.toString().equals(attrName)) {
}
if (Name.CONTENT_TYPE.toString().equals(attrName)) {
return Name.CONTENT_TYPE;
} else if (Name.EXTENSION_INSTALLATION.toString().equals(attrName)) {
}
if (Name.EXTENSION_INSTALLATION.toString().equals(attrName)) {
return Name.EXTENSION_INSTALLATION;
} else if (Name.EXTENSION_LIST.toString().equals(attrName)) {
}
if (Name.EXTENSION_LIST.toString().equals(attrName)) {
return Name.EXTENSION_LIST;
} else if (Name.EXTENSION_NAME.toString().equals(attrName)) {
}
if (Name.EXTENSION_NAME.toString().equals(attrName)) {
return Name.EXTENSION_NAME;
} else if (Name.IMPLEMENTATION_TITLE.toString().equals(attrName)) {
}
if (Name.IMPLEMENTATION_TITLE.toString().equals(attrName)) {
return Name.IMPLEMENTATION_TITLE;
} else if (Name.IMPLEMENTATION_URL.toString().equals(attrName)) {
}
if (Name.IMPLEMENTATION_URL.toString().equals(attrName)) {
return Name.IMPLEMENTATION_URL;
} else if (Name.IMPLEMENTATION_VENDOR.toString().equals(attrName)) {
}
if (Name.IMPLEMENTATION_VENDOR.toString().equals(attrName)) {
return Name.IMPLEMENTATION_VENDOR;
} else if (Name.IMPLEMENTATION_VENDOR_ID.toString().equals(attrName)) {
}
if (Name.IMPLEMENTATION_VENDOR_ID.toString().equals(attrName)) {
return Name.IMPLEMENTATION_VENDOR_ID;
} else if (Name.IMPLEMENTATION_VERSION.toString().equals(attrName)) {
}
if (Name.IMPLEMENTATION_VERSION.toString().equals(attrName)) {
return Name.IMPLEMENTATION_VENDOR;
} else if (Name.MAIN_CLASS.toString().equals(attrName)) {
}
if (Name.MAIN_CLASS.toString().equals(attrName)) {
return Name.MAIN_CLASS;
} else if (Name.MANIFEST_VERSION.toString().equals(attrName)) {
}
if (Name.MANIFEST_VERSION.toString().equals(attrName)) {
return Name.MANIFEST_VERSION;
} else if (Name.SEALED.toString().equals(attrName)) {
}
if (Name.SEALED.toString().equals(attrName)) {
return Name.SEALED;
} else if (Name.SIGNATURE_VERSION.toString().equals(attrName)) {
}
if (Name.SIGNATURE_VERSION.toString().equals(attrName)) {
return Name.SIGNATURE_VERSION;
} else if (Name.SPECIFICATION_TITLE.toString().equals(attrName)) {
}
if (Name.SPECIFICATION_TITLE.toString().equals(attrName)) {
return Name.SPECIFICATION_TITLE;
} else if (Name.SPECIFICATION_VENDOR.toString().equals(attrName)) {
}
if (Name.SPECIFICATION_VENDOR.toString().equals(attrName)) {
return Name.SPECIFICATION_VENDOR;
} else if (Name.SPECIFICATION_VERSION.toString().equals(attrName)) {
}
if (Name.SPECIFICATION_VERSION.toString().equals(attrName)) {
return Name.SPECIFICATION_VERSION;
} else {
return new Name(attrName);
}
return new Name(attrName);
}

/**
@@ -95,7 +95,8 @@ protected TarArchiveInputStream createTarFile(final File file) throws FileSystem
try {
if ("tgz".equalsIgnoreCase(getRootName().getScheme())) {
return new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(file)));
} else if ("tbz2".equalsIgnoreCase(getRootName().getScheme())) {
}
if ("tbz2".equalsIgnoreCase(getRootName().getScheme())) {
return new TarArchiveInputStream(
Bzip2FileObject.wrapInputStream(file.getAbsolutePath(), new FileInputStream(file)));
}
@@ -103,11 +103,10 @@ protected int countSlashes(final String fileName) {
continue;
}
} else if (state == 1) {
if (c == '/') {
nuofSlash++;
} else {
if (c != '/') {
return nuofSlash;
}
nuofSlash++;
}
}
return nuofSlash;
@@ -261,19 +261,22 @@ private static OsFamily determineOsFamily() {
return OS_FAMILY_WINNT;
}
return OS_FAMILY_WIN9X;
} else if (OS_NAME.contains("os/2")) {
}
if (OS_NAME.contains("os/2")) {
return OS_FAMILY_OS2;
} else if (OS_NAME.contains("netware")) {
}
if (OS_NAME.contains("netware")) {
return OS_FAMILY_NETWARE;
} else if (OS_NAME.contains("mac")) {
}
if (OS_NAME.contains("mac")) {
if (OS_NAME.endsWith("x")) {
return OS_FAMILY_OSX;
}
return OS_FAMILY_MAC;
} else if (PATH_SEP.equals(":")) {
}
if (PATH_SEP.equals(":")) {
return OS_FAMILY_UNIX;
} else {
return null;
}
return null;
}
}
@@ -57,7 +57,8 @@ public String getModeString() {
return "rw"; // NON-NLS
}
return "r"; // NON-NLS
} else if (requestWrite()) {
}
if (requestWrite()) {
return "w"; // NON-NLS
}

@@ -367,9 +367,8 @@ public void start(final Environment env) throws IOException {
if (command.equals("id -G") || command.equals("id -u")) {
if (isExecChannelClosed) {
throw new IOException();
} else {
new PrintStream(out).println(0);
}
new PrintStream(out).println(0);
} else if (NETCAT_COMMAND.matcher(command).matches()) {
final Matcher matcher = NETCAT_COMMAND.matcher(command);
matcher.matches();
@@ -66,13 +66,12 @@ private DocumentBuilder newDocumentBuilder(final FileObject containerFile, final
"http://www.w3.org/2001/XMLSchema");
@SuppressWarnings("resource")
final FileObject schema = containerFile.resolveFile(pathToXsdInZip);
if (schema.exists()) {
documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
schema.getContent().getInputStream());
} else {
if (!schema.exists()) {
schema.close();
throw new FileNotFoundException(schema.toString());
}
documentBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
schema.getContent().getInputStream());
}
DocumentBuilder documentBuilder = null;
try {

0 comments on commit 7b7f61c

Please sign in to comment.