owncloud/core

View on GitHub

Showing 3,235 of 4,504 total issues

Function beforeController has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function beforeController($controller, $methodName) {
        if ($this->reflector->hasAnnotation('PublicPage')) {
            // Don't block public pages
            return;
        }
Severity: Minor
Found in core/Middleware/AccountModuleMiddleware.php - About 45 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

Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $appName,
        IRequest $request,
        Manager $twoFactorManager,
        IUserSession $userSession,
        ISession $session,
Severity: Minor
Found in core/Controller/TwoFactorChallengeController.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (\substr_count((string)$_GET['search'], '@') >= 1) {
                            $shareWith[] = [
                                'label' => (string)$_GET['search'],
                                'value' => [
                                    'shareType' => \OCP\Share::SHARE_TYPE_REMOTE,
    Severity: Major
    Found in core/ajax/share.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if ((!isset($_GET['itemShares'])
                                  || !\is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])
                                  || !\in_array($uid, $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]))
                                  && $uid != OC_User::getUser()) {
                                  $shareWith[] = [
      Severity: Major
      Found in core/ajax/share.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if (\in_array($uid, $sharedUsers)) {
                                    continue;
                                }
        Severity: Major
        Found in core/ajax/share.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (isset($contact['CLOUD'])) {
                                      foreach ($contact['CLOUD'] as $cloudId) {
                                          $shareWith[] = [
                                              'label' => $contact['FN'] . ' (' . $cloudId . ')',
                                              'value' => [
          Severity: Major
          Found in core/ajax/share.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if (isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) &&
                                    \is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])) {
                                    $sharedGroups = $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP];
                                }
            Severity: Major
            Found in core/ajax/share.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if (isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) &&
                                      \is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) {
                                      $sharedUsers = $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER];
                                  }
              Severity: Major
              Found in core/ajax/share.php - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                                    if (
                                        params.code !== undefined
                                        && typeof client_id === "string"
                                        && client_id !== ''
                                        && typeof client_secret === "string"
                Severity: Major
                Found in apps/files_external/js/oauth2.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if (
                              !/^focus./.test(type) || (
                                  toElement === undefined &&
                                  originalEvent.fromElement === undefined &&
                                  originalEvent.relatedTarget === undefined
                  Severity: Major
                  Found in apps/files/js/jquery-visibility.js - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
                                params.data = options.attrs || model.toJSON(options);
                            }
                    Severity: Major
                    Found in core/js/oc-backbone-webdav.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                      if ((event.ctrlKey || event.metaKey) && // Ctrl or Command (OSX)
                                          !event.shiftKey &&
                                          event.keyCode === 70 && // F
                                          self.hasFilter(getCurrentApp()) && // Search is enabled
                                          !$searchBox.is(':focus') // if searchbox is already focused do nothing (fallback to browser default)
                      Severity: Major
                      Found in core/search/js/search.js - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if (!$foundRemoteById && \substr_count($search, '@') >= 1
                                    && $this->offset === 0 && $this->userSearch->isSearchable($search)
                                    // if an exact local user is found, only keep the remote entry if
                                    // its domain does not match the trusted domains
                                    // (if it does, it is a user whose local login domain matches the ownCloud
                        Severity: Major
                        Found in apps/files_sharing/lib/Controller/ShareesController.php - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if (
                                      $mode === 'w'
                                      || $mode === 'w+'
                                      || $mode === 'wb'
                                      || $mode === 'wb+'
                          Severity: Major
                          Found in lib/private/Files/Stream/Encryption.php - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                            if (($fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) ||
                                                (!$fileSharing && $item['item_source'] === $r['item_source'] && $item['item_target'] === $r['item_target'])) {
                                                // add the first item to the list of grouped shares
                                                if (!isset($result[$key]['grouped'])) {
                                                    $result[$key]['grouped'][] = $result[$key];
                            Severity: Major
                            Found in lib/private/Share/Share.php - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                              if ($includeCollections && $collectionTypes && $row['item_type'] !== 'folder' && \in_array($row['item_type'], $collectionTypes)) {
                                                  if (($collectionBackend = self::getBackend($row['item_type']))
                                                      && $collectionBackend instanceof \OCP\Share_Backend_Collection) {
                                                      // Collections can be inside collections, check if the item is a collection
                                                      if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) {
                              Severity: Major
                              Found in lib/private/Share/Share.php - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                            if (($type === 'bool' || $type === 'boolean') &&
                                                $value === 'false' &&
                                                (
                                                    $this->request->method === 'GET' ||
                                                    \strpos(
                                Severity: Major
                                Found in lib/private/AppFramework/Http/Dispatcher.php - About 40 mins to fix

                                  Function DeleteHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  function DeleteHandler(endpoint, paramID, markCallback, removeCallback, undoCallback) {
                                  Severity: Minor
                                  Found in settings/js/users/deleteHandler.js - About 35 mins to fix

                                    Function 1 has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                    templates['detailsview'] = template({"1":function(container,depth0,helpers,partials,data) {
                                    Severity: Minor
                                    Found in apps/files/js/templates/detailsview.handlebars.js - About 35 mins to fix

                                      Function main has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                      },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
                                      Severity: Minor
                                      Found in apps/files/js/templates/detailsview.handlebars.js - About 35 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language