File yf_ssh.class.php
has 554 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* SSH Client (based on SSH2 PHP extension).
*
Function connect
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function connect($server_info = [])
{
if ( ! $this->_INIT_OK || ! $server_info) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
yf_ssh
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class yf_ssh
{
// TODO: chained mode like in form and table, mass actions on one server, array of servers, named group(s) of servers:
// ssh('s23.dev')->exec('service memcached restart');
// ssh('s23*.dev')->exec('service memcached restart');
Function _skip_by_pattern
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function _skip_by_pattern($path = '', $_type = 'f', $pattern_include = '', $pattern_exclude = '')
{
if ( ! $path) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _perm_str2num
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function _perm_str2num($perm = '')
{
$perm_len = strlen(trim($perm));
if ($perm_len > 10 && $perm_len < 9) {
return false;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method connect
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function connect($server_info = [])
{
if ( ! $this->_INIT_OK || ! $server_info) {
return false;
}
Method _init_sftp_phpseclib
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _init_sftp_phpseclib($server_info = [])
{
if ( ! $this->DRIVER == 'phpseclib') {
return false;
}
Function _init_sftp_phpseclib
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function _init_sftp_phpseclib($server_info = [])
{
if ( ! $this->DRIVER == 'phpseclib') {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function shell_exec
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function shell_exec($server_info = [], $cmd = '')
{
if ( ! $this->_INIT_OK || ! $cmd || ! $server_info) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function exec
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function exec($server_info = [], $cmd = '')
{
if ( ! $this->_INIT_OK || ! $cmd || ! $server_info) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method shell_exec
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function shell_exec($server_info = [], $cmd = '')
{
if ( ! $this->_INIT_OK || ! $cmd || ! $server_info) {
return false;
}
Method exec
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function exec($server_info = [], $cmd = '')
{
if ( ! $this->_INIT_OK || ! $cmd || ! $server_info) {
return false;
}
Method _skip_by_pattern
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _skip_by_pattern($path = '', $_type = 'f', $pattern_include = '', $pattern_exclude = '')
{
if ( ! $path) {
return false;
}
Method _perm_str2num
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _perm_str2num($perm = '')
{
$perm_len = strlen(trim($perm));
if ($perm_len > 10 && $perm_len < 9) {
return false;
Method upload_dir
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function upload_dir($server_info = [], $local_dir = '', $remote_dir = '', $pattern_include = '', $pattern_exclude = '', $level = null)
Method scan_dir
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function scan_dir($server_info = [], $start_dir = '', $pattern_include = '', $pattern_exclude = '', $level = 0, $single_file = '')
Method download_dir
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function download_dir($server_info = [], $remote_dir = '', $local_dir = '', $pattern_include = '', $pattern_exclude = '', $level = null)
Method mkdir
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function mkdir($server_info = [], $dir_name = '', $dir_mode = 755, $create_index_htmls = 0, $start_folder = '')
Method chown
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function chown($server_info = [], $path = '', $new_owner = '', $new_group = '', $recursively = false)
Method mkdir_m
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function mkdir_m($server_info = [], $dir_name = '', $dir_mode = 755, $create_index_htmls/*!not implemented here!*/ = 0, $start_folder = '/')
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $con;
Avoid too many return
statements within this method. Open
return $data;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $data;
Avoid too many return
statements within this method. Open
return $con;
Avoid too many return
statements within this method. Open
return $this->_sftp_connected[$_SERVER_ID];
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Function _init
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function _init()
{
if ( ! $this->DRIVER) {
$this->DRIVER = 'phpseclib';
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( ! $use_pswd) {
$key = new Crypt_RSA();
if ($server_info['ssh_key_pswd']) {
$key->setPassword($server_info['ssh_key_pswd']); // password for key
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 125.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( ! $use_pswd) {
$key = new Crypt_RSA();
if ($server_info['ssh_key_pswd']) {
$key->setPassword($server_info['ssh_key_pswd']); // password for key
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 125.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76