Showing 2,255 of 2,255 total issues
Function detectPHPLinux
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function detectPHPLinux($options = [], $searchOrder = null)
{
if ($searchOrder === null) {
$searchOrder = [
['command', ['-v', 'php']],
- 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 restoreDatabase
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function restoreDatabase(Database $database, string $remoteFile, bool $clone)
{
$tmp = tempnam($_ENV['TEMP_FOLDER'], 'dblocal');
if (! empty($database->dbLocalContent)) {
- 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 setSafeDirectory
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function setSafeDirectory($instance)
{
$skipSafeDir = isset($_ENV['GIT_DONT_ADD_SAFEDIR']) ? (bool) $_ENV['GIT_DONT_ADD_SAFEDIR'] : false;
if ($skipSafeDir) {
- 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 install
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function install(Version $version, $checksumCheck = false, $revision = null)
{
$access = $this->instance->getBestAccess('scripting');
$host = $access->getHost();
Method setSafeDirectory
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function setSafeDirectory($instance)
{
$skipSafeDir = isset($_ENV['GIT_DONT_ADD_SAFEDIR']) ? (bool) $_ENV['GIT_DONT_ADD_SAFEDIR'] : false;
if ($skipSafeDir) {
Method setupRemoteAccess
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setupRemoteAccess(Access $access)
{
$host = $this->io->ask('Host', $this->input->getOption('host') ?? '', function ($value) {
return !empty($value) ? $value : new InvalidOptionException("You must provide a valid remote host. Please use --host=<HOST>");
});
Method interact
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function interact(InputInterface $input, OutputInterface $output)
{
if (empty($input->getOption('instance'))) {
if (empty($this->instancesInfo)) {
return;
Method interact
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function interact(InputInterface $input, OutputInterface $output)
{
$instances = CommandHelper::getInstances('tiki');
$instancesInfo = CommandHelper::getInstancesInfo($instances);
Method windowsSync
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function windowsSync($remoteLocation, $localMirror, $files = [], $exclusions = [])
{
$exclude = '';
$returnVar = 0;
The class Instance has 25 fields. Consider redesigning Instance to keep the number of fields under 15. Open
class Instance
{
const TYPES = 'local,ftp,ssh';
const SQL_SELECT_INSTANCE = <<<SQL
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method interact
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function interact(InputInterface $input, OutputInterface $output)
{
if (empty($input->getOption('time'))) {
$answer = $this->io->ask('What time should it run at?', '00:00', function ($answer) {
return CommandHelper::validateTimeInput($answer);
Method execute
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$time = $input->getOption('time');
list($hours, $minutes) = CommandHelper::validateTimeInput($time);
$arguments = '--instances=all --no-interaction';
Method execute
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$instance = Instance::getInstance($input->getOption('instance'));
if (empty($instance)) {
$this->io->warning('No Tiki instances available.');
Method execute
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$instance = new Instance();
try {
if ($input->isInteractive()) {
Method interact
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function interact(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('question');
$email = $input->getOption('email');
if (empty($email) || ! filter_var($email, FILTER_VALIDATE_EMAIL)) {
Method handleInstance
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handleInstance(Instance $instance, InputInterface $input): Instance\CronJob
{
$this->io->section($instance->name);
$instanceOS = $instance->getDiscovery()->detectOS();
Method fixPermissions
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fixPermissions($path)
{
$filesystem = new Filesystem();
$perm = $this->getFilePerm();
$user = $this->getFileUser();
Method decompressArchive
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function decompressArchive($folder, $archive)
{
$access = $this->access;
$bzipStep = false;
Method extractTo
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function extractTo(Version $version, $folder, $revision = null): void
{
$dirExists = file_exists($folder);
if ($dirExists && preg_match('/tags\\//', $version->branch)) {
Method fixPermissions
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fixPermissions()
{
$instance = $this->instance;
$access = $instance->getBestAccess('scripting');