mdmsoft/yii2-admin

View on GitHub

Showing 114 of 114 total issues

File AuthItem.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace mdm\admin\models;

use mdm\admin\components\Configs;
Severity: Minor
Found in models/AuthItem.php - About 2 hrs to fix

    Function keydown has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                keydown: function( event ) {
                    if ( this.element.prop( "readOnly" ) ) {
                        suppressKeyPress = true;
                        suppressInput = true;
                        suppressKeyPressRepeat = true;
    Severity: Major
    Found in assets/jquery-ui.js - About 2 hrs to fix

      Function getRoutesByUser has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getRoutesByUser($userId)
          {
              if (!isset(self::$_userRoutes[$userId])) {
                  $cache = Configs::cache();
                  if ($cache && ($routes = $cache->get([__METHOD__, $userId])) !== false) {
      Severity: Minor
      Found in components/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

      Function bridge has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      $.widget.bridge = function( name, object ) {
          var fullName = object.prototype.widgetFullName || name;
          $.fn[ name ] = function( options ) {
              var isMethodCall = typeof options === "string",
                  args = widget_slice.call( arguments, 1 ),
      Severity: Minor
      Found in assets/jquery-ui.js - About 1 hr to fix

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

            public function revoke($items)
            {
                $manager = Configs::authManager();
                $success = 0;
                foreach ($items as $name) {
        Severity: Major
        Found in models/Assignment.php and 1 other location - About 1 hr to fix
        models/Assignment.php on lines 41..57

        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 117.

        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

            public function assign($items)
            {
                $manager = Configs::authManager();
                $success = 0;
                foreach ($items as $name) {
        Severity: Major
        Found in models/Assignment.php and 1 other location - About 1 hr to fix
        models/Assignment.php on lines 64..80

        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 117.

        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

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

            public function getUsers()
            {
                $module = Yii::$app->controller->module;
                if (!$module || !$module instanceof Module) {
                    return [];
        Severity: Minor
        Found in models/AuthItem.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 getRoutes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getRoutes()
            {
                $manager = Configs::authManager();
                // Get advanced configuration
                $advanced = Configs::instance()->advanced;
        Severity: Minor
        Found in models/Route.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 getControllerFiles has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getControllerFiles($module, $namespace, $prefix, &$result)
            {
                $path = Yii::getAlias('@' . str_replace('\\', '/', $namespace), false);
                $token = "Get controllers from '$path'";
                Yii::beginProfile($token, __METHOD__);
        Severity: Minor
        Found in models/Route.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 name has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            $.fn[ name ] = function( options ) {
                var isMethodCall = typeof options === "string",
                    args = widget_slice.call( arguments, 1 ),
                    returnValue = this;
        
        
        Severity: Minor
        Found in assets/jquery-ui.js - About 1 hr to fix

          Method isActive has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function isActive($action)
              {
                  $uniqueId = $action->getUniqueId();
                  if ($uniqueId === Yii::$app->getErrorHandler()->errorAction) {
                      return false;
          Severity: Minor
          Found in components/AccessControl.php - About 1 hr to fix

            Function refresh has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                refresh: function() {
                    var menus, items,
                        that = this,
                        icon = this.options.icons.submenu,
                        submenus = this.element.find( this.options.menus );
            Severity: Minor
            Found in assets/jquery-ui.js - About 1 hr to fix

              Method getUsers has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getUsers()
                  {
                      $module = Yii::$app->controller->module;
                      if (!$module || !$module instanceof Module) {
                          return [];
              Severity: Minor
              Found in models/AuthItem.php - About 1 hr to fix

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

                    public function save()
                    {
                        if ($this->validate()) {
                            $manager = Configs::authManager();
                            if ($this->_item === null) {
                Severity: Minor
                Found in models/AuthItem.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 search has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function search($params)
                    {
                        /* @var \yii\rbac\Manager $authManager */
                        $authManager = Configs::authManager();
                        $advanced = Configs::instance()->advanced;
                Severity: Minor
                Found in models/searchs/AuthItem.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

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

                        left: function() {
                            $.ui.position.flip.left.apply( this, arguments );
                            $.ui.position.fit.left.apply( this, arguments );
                        },
                Severity: Major
                Found in assets/jquery-ui.js and 1 other location - About 1 hr to fix
                assets/jquery-ui.js on lines 1315..1318

                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 66.

                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

                        top: function() {
                            $.ui.position.flip.top.apply( this, arguments );
                            $.ui.position.fit.top.apply( this, arguments );
                        }
                Severity: Major
                Found in assets/jquery-ui.js and 1 other location - About 1 hr to fix
                assets/jquery-ui.js on lines 1311..1314

                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 66.

                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

                Function _on has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _on: function( suppressDisabledCheck, element, handlers ) {
                        var delegateElement,
                            instance = this;
                
                        // no suppressDisabledCheck flag, shuffle arguments
                Severity: Minor
                Found in assets/jquery-ui.js - About 1 hr to fix

                  Method getRoutes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getRoutes()
                      {
                          $manager = Configs::authManager();
                          // Get advanced configuration
                          $advanced = Configs::instance()->advanced;
                  Severity: Minor
                  Found in models/Route.php - About 1 hr to fix

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

                            if ( options.my[ 1 ] === "bottom" ) {
                                position.top -= elemHeight;
                            } else if ( options.my[ 1 ] === "center" ) {
                                position.top -= elemHeight / 2;
                            }
                    Severity: Major
                    Found in assets/jquery-ui.js and 3 other locations - About 1 hr to fix
                    assets/jquery-ui.js on lines 1046..1050
                    assets/jquery-ui.js on lines 1052..1056
                    assets/jquery-ui.js on lines 1074..1078

                    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 65.

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language