Changed per codacy feedback

- changed variable scope in SshConnectionPool.ConnectionInfo
- use extra temp variable for SshClientUtils.deriveSftpPathFrom()
This commit is contained in:
TranceLove
2020-10-06 23:23:11 +08:00
parent ea846a56ca
commit 455456a223
2 changed files with 9 additions and 8 deletions
@@ -296,10 +296,11 @@ public abstract class SshClientUtils {
@Nullable String password,
@Nullable KeyPair selectedParsedKeyPair) {
// FIXME: should be caller's responsibility
if (defaultPath == null) defaultPath = "/";
String pathSuffix = defaultPath;
if (pathSuffix == null) pathSuffix = "/";
return (selectedParsedKeyPair != null || password == null)
? String.format("ssh://%s@%s:%d%s", username, hostname, port, defaultPath)
: String.format("ssh://%s:%s@%s:%d%s", username, password, hostname, port, defaultPath);
? String.format("ssh://%s@%s:%d%s", username, hostname, port, pathSuffix)
: String.format("ssh://%s:%s@%s:%d%s", username, password, hostname, port, pathSuffix);
}
public static boolean isDirectory(@NonNull SFTPClient client, @NonNull RemoteResourceInfo info)
@@ -260,11 +260,11 @@ public class SshConnectionPool {
*/
static final class ConnectionInfo {
final String host;
final int port;
final String username;
final String password;
final String defaultPath;
protected final String host;
protected final int port;
protected final String username;
protected final String password;
protected final String defaultPath;
// FIXME: Crude assumption
ConnectionInfo(@NonNull String url) {