owncloud/core

View on GitHub
apps/files_sharing/lib/ShareBackend/File.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method formatItems has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function formatItems($items, $format, $parameters = null) {
        if ($format == self::FORMAT_SHARED_STORAGE) {
            // Only 1 item should come through for this format call
            $item = \array_shift($items);
            return [
Severity: Major
Found in apps/files_sharing/lib/ShareBackend/File.php - About 2 hrs to fix

    Function formatItems has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function formatItems($items, $format, $parameters = null) {
            if ($format == self::FORMAT_SHARED_STORAGE) {
                // Only 1 item should come through for this format call
                $item = \array_shift($items);
                return [
    Severity: Minor
    Found in apps/files_sharing/lib/ShareBackend/File.php - About 2 hrs 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 resolveReshares has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function resolveReshares($source) {
            if (isset($source['parent'])) {
                $parent = $source['parent'];
                while (isset($parent)) {
                    $query = \OCP\DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
    Severity: Minor
    Found in apps/files_sharing/lib/ShareBackend/File.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

    Function generateTarget has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generateTarget($filePath, $shareWith, $exclude = null) {
            $shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
            $target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . \basename($filePath));
    
            // for group shares we return the target right away
    Severity: Minor
    Found in apps/files_sharing/lib/ShareBackend/File.php - About 35 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

    Avoid too many return statements within this method.
    Open

            return [];
    Severity: Major
    Found in apps/files_sharing/lib/ShareBackend/File.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return $filePermissions;
      Severity: Major
      Found in apps/files_sharing/lib/ShareBackend/File.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $targets;
        Severity: Major
        Found in apps/files_sharing/lib/ShareBackend/File.php - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status