You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tiene un Long parameter list en la clase abstractSshShell esto hace que el código no sea fácil de mantener y modificar podrían a ver complicaciones en el mantenimiento del código. También una lista larga de parámetros puede indicar que está tratando de hacer demasiado y esto puede violar el principio de responsabilidad única.
Recfactorizado
Después
@ToString
@EqualsAndHashCode(of = { "addr", "port", "login" })
@Getter
@SuppressWarnings({ "PMD.UnusedPrivateField", "PMD.SingularField" })
abstract class AbstractSshShell implements Shell {
/**
* IP address of the server.
*/
private final transient String addr;
/**
* Port to use.
*/
private final transient int port;
/**
* User name.
*/
private final transient String login;
// Introduce Parameter Object for the constructor
@ToString
@EqualsAndHashCode
static class SshConfig {
private final String address;
private final int port;
private final String user;
SshConfig(final String adr, final int prt, final String user) {
this.address = adr;
this.port = prt;
this.user = user;
}
}
/**
* Constructor.
* @param config SshConfig containing address, port, and user.
* @throws UnknownHostException when host is unknown.
*/
AbstractSshShell(final SshConfig config) throws UnknownHostException {
this.addr = InetAddress.getByName(config.address).getHostAddress();
this.port = config.port;
this.login = config.user;
}
@Override
public int exec(final String command, final InputStream stdin,
final OutputStream stdout, final OutputStream stderr)
throws IOException {
return new Execution(
command,
stdin,
stdout,
stderr,
this.session()
).exec();
}
protected abstract Session session() throws IOException;
}
The text was updated successfully, but these errors were encountered:
Tarea Reactoring
Tiene un Long parameter list en la clase abstractSshShell esto hace que el código no sea fácil de mantener y modificar podrían a ver complicaciones en el mantenimiento del código. También una lista larga de parámetros puede indicar que está tratando de hacer demasiado y esto puede violar el principio de responsabilidad única.
Recfactorizado
The text was updated successfully, but these errors were encountered: