owncloud/core

View on GitHub
apps/files_sharing/lib/Helper.php

Summary

Maintainability
C
1 day
Test Coverage

Function getShareFolder has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getShareFolder($view = null) {
        if ($view === null) {
            $view = Filesystem::getView();
        }
        // for guests we default to root as their home storage is read-only
Severity: Minor
Found in apps/files_sharing/lib/Helper.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 authenticate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function authenticate($linkItem, $password = null) {
        if ($password !== null) {
            if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_LINK) {
                // Check Password
                $newHash = '';
Severity: Minor
Found in apps/files_sharing/lib/Helper.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

Method setupFromToken has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function setupFromToken($token, $relativePath = null, $password = null) {
        \OC_User::setIncognitoMode(true);

        $linkItem = \OCP\Share::getShareByToken($token, !$password);
        if ($linkItem === false || ($linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder')) {
Severity: Minor
Found in apps/files_sharing/lib/Helper.php - About 1 hr to fix

    Function setupFromToken has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function setupFromToken($token, $relativePath = null, $password = null) {
            \OC_User::setIncognitoMode(true);
    
            $linkItem = \OCP\Share::getShareByToken($token, !$password);
            if ($linkItem === false || ($linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder')) {
    Severity: Minor
    Found in apps/files_sharing/lib/Helper.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 getShareFolder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getShareFolder($view = null) {
            if ($view === null) {
                $view = Filesystem::getView();
            }
            // for guests we default to root as their home storage is read-only
    Severity: Minor
    Found in apps/files_sharing/lib/Helper.php - About 1 hr to fix

      Method getSharesFromItem has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getSharesFromItem($target) {
              $result = [];
              $owner = Filesystem::getOwner($target);
              Filesystem::initMountPoints($owner);
              $info = Filesystem::getFileInfo($target);
      Severity: Minor
      Found in apps/files_sharing/lib/Helper.php - About 1 hr to fix

        Function getSharesFromItem has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getSharesFromItem($target) {
                $result = [];
                $owner = Filesystem::getOwner($target);
                Filesystem::initMountPoints($owner);
                $info = Filesystem::getFileInfo($target);
        Severity: Minor
        Found in apps/files_sharing/lib/Helper.php - About 55 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