wikimedia/mediawiki-core

View on GitHub
includes/Permissions/PermissionManager.php

Summary

Maintainability
F
1 wk
Test Coverage

File PermissionManager.php has 1134 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Major
Found in includes/Permissions/PermissionManager.php - About 2 days to fix

    Function checkActionPermissions has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

        private function checkActionPermissions(
            $action,
            User $user,
            $errors,
            $rigor,
    Severity: Minor
    Found in includes/Permissions/PermissionManager.php - About 7 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 checkQuickPermissions has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        private function checkQuickPermissions(
            $action,
            User $user,
            $errors,
            $rigor,
    Severity: Minor
    Found in includes/Permissions/PermissionManager.php - About 5 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 checkReadPermissions has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        private function checkReadPermissions(
            $action,
            User $user,
            $errors,
            $rigor,
    Severity: Minor
    Found in includes/Permissions/PermissionManager.php - About 4 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

    PermissionManager has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PermissionManager {
    
        /** @var string Does cheap permission checks from replica DBs (usable for GUI creation) */
        public const RIGOR_QUICK = 'quick';
    
    
    Severity: Minor
    Found in includes/Permissions/PermissionManager.php - About 4 hrs to fix

      Function getNamespaceRestrictionLevels has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getNamespaceRestrictionLevels( $index, UserIdentity $user = null ): array {
              if ( !isset( $this->options->get( MainConfigNames::NamespaceProtection )[$index] ) ) {
                  // All levels are valid if there's no namespace restriction.
                  // But still filter by user, if necessary
                  $levels = $this->options->get( MainConfigNames::RestrictionLevels );
      Severity: Minor
      Found in includes/Permissions/PermissionManager.php - About 3 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 checkActionPermissions has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function checkActionPermissions(
              $action,
              User $user,
              $errors,
              $rigor,
      Severity: Major
      Found in includes/Permissions/PermissionManager.php - About 3 hrs to fix

        Function checkCascadingSourcesRestrictions has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            private function checkCascadingSourcesRestrictions(
                $action,
                UserIdentity $user,
                $errors,
                $rigor,
        Severity: Minor
        Found in includes/Permissions/PermissionManager.php - About 3 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 getApplicableBlock has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getApplicableBlock(
                string $action,
                User $user,
                string $rigor,
                $page,
        Severity: Major
        Found in includes/Permissions/PermissionManager.php - About 3 hrs to fix

          Method checkQuickPermissions has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function checkQuickPermissions(
                  $action,
                  User $user,
                  $errors,
                  $rigor,
          Severity: Major
          Found in includes/Permissions/PermissionManager.php - About 2 hrs to fix

            Method getPermissionErrorsInternal has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getPermissionErrorsInternal(
                    $action,
                    User $user,
                    LinkTarget $page,
                    $rigor = self::RIGOR_SECURE,
            Severity: Major
            Found in includes/Permissions/PermissionManager.php - About 2 hrs to fix

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

                  public function getApplicableBlock(
                      string $action,
                      User $user,
                      string $rigor,
                      $page,
              Severity: Minor
              Found in includes/Permissions/PermissionManager.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 checkUserConfigPermissions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function checkUserConfigPermissions(
                      $action,
                      UserIdentity $user,
                      $errors,
                      $rigor,
              Severity: Minor
              Found in includes/Permissions/PermissionManager.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 checkReadPermissions has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function checkReadPermissions(
                      $action,
                      User $user,
                      $errors,
                      $rigor,
              Severity: Major
              Found in includes/Permissions/PermissionManager.php - About 2 hrs to fix

                Method getNamespaceRestrictionLevels has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getNamespaceRestrictionLevels( $index, UserIdentity $user = null ): array {
                        if ( !isset( $this->options->get( MainConfigNames::NamespaceProtection )[$index] ) ) {
                            // All levels are valid if there's no namespace restriction.
                            // But still filter by user, if necessary
                            $levels = $this->options->get( MainConfigNames::RestrictionLevels );
                Severity: Minor
                Found in includes/Permissions/PermissionManager.php - About 2 hrs to fix

                  Method checkUserConfigPermissions has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function checkUserConfigPermissions(
                          $action,
                          UserIdentity $user,
                          $errors,
                          $rigor,
                  Severity: Minor
                  Found in includes/Permissions/PermissionManager.php - About 1 hr to fix

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

                            ServiceOptions $options,
                            SpecialPageFactory $specialPageFactory,
                            NamespaceInfo $nsInfo,
                            GroupPermissionsLookup $groupPermissionsLookup,
                            UserGroupManager $userGroupManager,
                    Severity: Major
                    Found in includes/Permissions/PermissionManager.php - About 1 hr to fix

                      Function getUserPermissions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function getUserPermissions( UserIdentity $user ): array {
                              $rightsCacheKey = $this->getRightsCacheKey( $user );
                              if ( !isset( $this->usersRights[ $rightsCacheKey ] ) ) {
                                  $userObj = $this->userFactory->newFromUserIdentity( $user );
                                  $rights = $this->groupPermissionsLookup->getGroupPermissions(
                      Severity: Minor
                      Found in includes/Permissions/PermissionManager.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 getPermissionErrorsInternal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getPermissionErrorsInternal(
                              $action,
                              User $user,
                              LinkTarget $page,
                              $rigor = self::RIGOR_SECURE,
                      Severity: Minor
                      Found in includes/Permissions/PermissionManager.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 getUserPermissions has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getUserPermissions( UserIdentity $user ): array {
                              $rightsCacheKey = $this->getRightsCacheKey( $user );
                              if ( !isset( $this->usersRights[ $rightsCacheKey ] ) ) {
                                  $userObj = $this->userFactory->newFromUserIdentity( $user );
                                  $rights = $this->groupPermissionsLookup->getGroupPermissions(
                      Severity: Minor
                      Found in includes/Permissions/PermissionManager.php - About 1 hr to fix

                        Function checkPageRestrictions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function checkPageRestrictions(
                                $action,
                                User $user,
                                $errors,
                                $rigor,
                        Severity: Minor
                        Found in includes/Permissions/PermissionManager.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 isEveryoneAllowed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function isEveryoneAllowed( $right ): bool {
                                // Use the cached results, except in unit tests which rely on
                                // being able change the permission mid-request
                                if ( isset( $this->cachedRights[$right] ) ) {
                                    return $this->cachedRights[$right];
                        Severity: Minor
                        Found in includes/Permissions/PermissionManager.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 isEveryoneAllowed has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function isEveryoneAllowed( $right ): bool {
                                // Use the cached results, except in unit tests which rely on
                                // being able change the permission mid-request
                                if ( isset( $this->cachedRights[$right] ) ) {
                                    return $this->cachedRights[$right];
                        Severity: Minor
                        Found in includes/Permissions/PermissionManager.php - About 1 hr to fix

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

                                  $action,
                                  User $user,
                                  $errors,
                                  $rigor,
                                  $short,
                          Severity: Minor
                          Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                    $action,
                                    UserIdentity $user,
                                    $errors,
                                    $rigor,
                                    $short,
                            Severity: Minor
                            Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                      $action,
                                      User $user,
                                      $errors,
                                      $rigor,
                                      $short,
                              Severity: Minor
                              Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                        $action,
                                        UserIdentity $user,
                                        $errors,
                                        $rigor,
                                        $short,
                                Severity: Minor
                                Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                          $action,
                                          UserIdentity $user,
                                          $errors,
                                          $rigor,
                                          $short,
                                  Severity: Minor
                                  Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                            $action,
                                            User $user,
                                            $errors,
                                            $rigor,
                                            $short,
                                    Severity: Minor
                                    Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                              $action,
                                              User $user,
                                              $errors,
                                              $rigor,
                                              $short,
                                      Severity: Minor
                                      Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                                $action,
                                                User $user,
                                                $errors,
                                                $rigor,
                                                $short,
                                        Severity: Minor
                                        Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                                  $action,
                                                  User $user,
                                                  $errors,
                                                  $rigor,
                                                  $short,
                                          Severity: Minor
                                          Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

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

                                                    $action,
                                                    User $user,
                                                    $errors,
                                                    $rigor,
                                                    $short,
                                            Severity: Minor
                                            Found in includes/Permissions/PermissionManager.php - About 45 mins to fix

                                              Consider simplifying this complex logical expression.
                                              Open

                                                              if ( $user->isAnon()
                                                                  && ( $userCanMove || $namedCanMove || $autoconfirmedCanMove )
                                                              ) {
                                                                  // custom message if logged-in users without any special rights can move
                                                                  $errors[] = [ 'movenologintext' ];
                                              Severity: Major
                                              Found in includes/Permissions/PermissionManager.php - About 40 mins to fix

                                                Method getPermissionErrors has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                        $action,
                                                        User $user,
                                                        LinkTarget $page,
                                                        $rigor = self::RIGOR_SECURE,
                                                        $ignoreErrors = []
                                                Severity: Minor
                                                Found in includes/Permissions/PermissionManager.php - About 35 mins to fix

                                                  Method getPermissionErrorsInternal has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                  Open

                                                          $action,
                                                          User $user,
                                                          LinkTarget $page,
                                                          $rigor = self::RIGOR_SECURE,
                                                          $short = false
                                                  Severity: Minor
                                                  Found in includes/Permissions/PermissionManager.php - About 35 mins to fix

                                                    Method throwPermissionErrors has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                            $action,
                                                            User $user,
                                                            LinkTarget $page,
                                                            $rigor = self::RIGOR_SECURE,
                                                            $ignoreErrors = []
                                                    Severity: Minor
                                                    Found in includes/Permissions/PermissionManager.php - About 35 mins to fix

                                                      Method getApplicableBlock has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                              string $action,
                                                              User $user,
                                                              string $rigor,
                                                              $page,
                                                              ?WebRequest $request
                                                      Severity: Minor
                                                      Found in includes/Permissions/PermissionManager.php - About 35 mins to fix

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

                                                            private function checkSiteConfigPermissions(
                                                                $action,
                                                                User $user,
                                                                $errors,
                                                                $rigor,
                                                        Severity: Minor
                                                        Found in includes/Permissions/PermissionManager.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 true;
                                                        Severity: Major
                                                        Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                                  return $originalBlock->appliesToTitle( $targetTitle );
                                                          Severity: Major
                                                          Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                        return null;
                                                            Severity: Major
                                                            Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                          return false;
                                                              Severity: Major
                                                              Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                            return null;
                                                                Severity: Major
                                                                Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return $originalBlock->appliesToRight( $action ) !== false;
                                                                  Severity: Major
                                                                  Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return true;
                                                                    Severity: Major
                                                                    Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                              return $block;
                                                                      Severity: Major
                                                                      Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                                return $originalBlock->appliesToUsertalk( $targetTitle );
                                                                        Severity: Major
                                                                        Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                      return null;
                                                                          Severity: Major
                                                                          Found in includes/Permissions/PermissionManager.php - About 30 mins to fix

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

                                                                                private function resultToError( $errors, $result ): array {
                                                                                    if ( is_array( $result ) && count( $result ) && !is_array( $result[0] ) ) {
                                                                                        // A single array representing an error
                                                                                        $errors[] = $result;
                                                                                    } elseif ( is_array( $result ) && is_array( $result[0] ) ) {
                                                                            Severity: Minor
                                                                            Found in includes/Permissions/PermissionManager.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 getPermissionErrors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                            Open

                                                                                public function getPermissionErrors(
                                                                                    $action,
                                                                                    User $user,
                                                                                    LinkTarget $page,
                                                                                    $rigor = self::RIGOR_SECURE,
                                                                            Severity: Minor
                                                                            Found in includes/Permissions/PermissionManager.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

                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                            Open

                                                                                    if ( $title->isSiteCssConfigPage() && !$this->userHasRight( $user, 'editsitecss' ) ) {
                                                                                        $errors[] = [ 'sitecssprotected', $action ];
                                                                                    } elseif ( $title->isSiteJsonConfigPage() && !$this->userHasRight( $user, 'editsitejson' ) ) {
                                                                                        $errors[] = [ 'sitejsonprotected', $action ];
                                                                                    } elseif ( $title->isSiteJsConfigPage() && !$this->userHasRight( $user, 'editsitejs' ) ) {
                                                                            Severity: Major
                                                                            Found in includes/Permissions/PermissionManager.php and 1 other location - About 1 hr to fix
                                                                            includes/Permissions/PermissionManager.php on lines 1499..1514

                                                                            Duplicated Code

                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                            Tuning

                                                                            This issue has a mass of 115.

                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                            Refactorings

                                                                            Further Reading

                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                            Open

                                                                                        if (
                                                                                            $title->isUserCssConfigPage()
                                                                                            && !$this->userHasRight( $user, 'editusercss' )
                                                                                        ) {
                                                                                            $errors[] = [ 'customcssprotected', $action ];
                                                                            Severity: Major
                                                                            Found in includes/Permissions/PermissionManager.php and 1 other location - About 1 hr to fix
                                                                            includes/Permissions/PermissionManager.php on lines 1421..1427

                                                                            Duplicated Code

                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                            Tuning

                                                                            This issue has a mass of 115.

                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                            Refactorings

                                                                            Further Reading

                                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                                            Open

                                                                                public function __construct(
                                                                                    ServiceOptions $options,
                                                                                    SpecialPageFactory $specialPageFactory,
                                                                                    NamespaceInfo $nsInfo,
                                                                                    GroupPermissionsLookup $groupPermissionsLookup,
                                                                            Severity: Major
                                                                            Found in includes/Permissions/PermissionManager.php and 2 other locations - About 1 hr to fix
                                                                            includes/auth/AuthManager.php on lines 260..294
                                                                            includes/page/UndeletePage.php on lines 126..159

                                                                            Duplicated Code

                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                            Tuning

                                                                            This issue has a mass of 106.

                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                            Refactorings

                                                                            Further Reading

                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                            Open

                                                                                    } elseif ( $action === 'move' ) {
                                                                                        // Check for immobile pages
                                                                                        if ( !$this->nsInfo->isMovable( $title->getNamespace() ) ) {
                                                                                            // Specific message for this case
                                                                                            $nsText = $title->getNsText();
                                                                            Severity: Minor
                                                                            Found in includes/Permissions/PermissionManager.php and 1 other location - About 1 hr to fix
                                                                            includes/Permissions/PermissionManager.php on lines 1271..1281

                                                                            Duplicated Code

                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                            Tuning

                                                                            This issue has a mass of 100.

                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                            Refactorings

                                                                            Further Reading

                                                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                                                            Open

                                                                                    } elseif ( $action === 'move-target' ) {
                                                                                        if ( !$this->nsInfo->isMovable( $title->getNamespace() ) ) {
                                                                                            $nsText = $title->getNsText();
                                                                                            if ( $nsText === '' ) {
                                                                                                $nsText = wfMessage( 'blanknamespace' )->text();
                                                                            Severity: Minor
                                                                            Found in includes/Permissions/PermissionManager.php and 1 other location - About 1 hr to fix
                                                                            includes/Permissions/PermissionManager.php on lines 1258..1271

                                                                            Duplicated Code

                                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                            Tuning

                                                                            This issue has a mass of 100.

                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                            Refactorings

                                                                            Further Reading

                                                                            There are no issues that match your filters.

                                                                            Category
                                                                            Status