owncloud/core

View on GitHub
apps/files_external/lib/Lib/Storage/SFTP.php

Summary

Maintainability
C
1 day
Test Coverage

File SFTP.php has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Andreas Fischer <bantu@owncloud.com>
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author hkjolhede <hkjolhede@gmail.com>
Severity: Minor
Found in apps/files_external/lib/Lib/Storage/SFTP.php - About 2 hrs to fix

    SFTP has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SFTP extends \OCP\Files\Storage\StorageAdapter {
        private $host;
        private $user;
        private $root;
        private $port = 22;
    Severity: Minor
    Found in apps/files_external/lib/Lib/Storage/SFTP.php - About 2 hrs to fix

      Function readHostKeys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function readHostKeys() {
              try {
                  $keyPath = $this->hostKeysPath();
                  if (\file_exists($keyPath)) {
                      $hosts = [];
      Severity: Minor
      Found in apps/files_external/lib/Lib/Storage/SFTP.php - About 1 hr to fix

      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 fopen has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function fopen($path, $mode) {
              try {
                  $absPath = $this->absPath($path);
                  switch ($mode) {
                      case 'r':
      Severity: Minor
      Found in apps/files_external/lib/Lib/Storage/SFTP.php - About 1 hr to fix

        Function __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct($params) {
                // Register sftp://
                Stream::register();
        
                $parsedHost =  $this->splitHost($params['host']);
        Severity: Minor
        Found in apps/files_external/lib/Lib/Storage/SFTP.php - About 25 mins to fix

        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 opendir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function opendir($path) {
                try {
                    $list = $this->getConnection()->nlist($this->absPath($path));
                    if ($list === false) {
                        return false;
        Severity: Minor
        Found in apps/files_external/lib/Lib/Storage/SFTP.php - About 25 mins to fix

        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 getConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getConnection() {
                if ($this->client !== null) {
                    return $this->client;
                }
        
        
        Severity: Minor
        Found in apps/files_external/lib/Lib/Storage/SFTP.php - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status