mdmsoft/yii2-admin

View on GitHub

Showing 114 of 114 total issues

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

        if ($this->_item !== null) {
            foreach ($items as $name) {
                $child = $manager->getPermission($name);
                if ($this->type == Item::TYPE_ROLE && $child === null) {
                    $child = $manager->getRole($name);
Severity: Major
Found in models/AuthItem.php and 1 other location - About 1 hr to fix
models/AuthItem.php on lines 198..211

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

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 _initSource has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _initSource: function() {
        var array, url,
            that = this;
        if ( $.isArray( this.options.source ) ) {
            array = this.options.source;
Severity: Minor
Found in assets/jquery-ui.js - About 1 hr to fix

    Function _destroy has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _destroy: function() {
            // Destroy (sub)menus
            this.element
                .removeAttr( "aria-activedescendant" )
                .find( ".ui-menu" ).addBack()
    Severity: Minor
    Found in assets/jquery-ui.js - About 1 hr to fix

      Function _createWidget has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _createWidget: function( options, element ) {
              element = $( element || this.defaultElement || this )[ 0 ];
              this.element = $( element );
              this.uuid = widget_uuid++;
              this.eventNamespace = "." + this.widgetName + this.uuid;
      Severity: Minor
      Found in assets/jquery-ui.js - About 1 hr to fix

        Method addNew has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addNew($routes)
            {
                $manager = Configs::authManager();
                foreach ($routes as $route) {
                    try {
        Severity: Minor
        Found in models/Route.php - About 1 hr to fix

          Function left has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  left: function( position, data ) {
                      var within = data.within,
                          withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
                          outerWidth = within.width,
                          collisionPosLeft = position.left - data.collisionPosition.marginLeft,
          Severity: Minor
          Found in assets/jquery-ui.js - About 1 hr to fix

            Function getDimensions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getDimensions( elem ) {
                var raw = elem[0];
                if ( raw.nodeType === 9 ) {
                    return {
                        width: elem.width(),
            Severity: Minor
            Found in assets/jquery-ui.js - About 1 hr to fix

              Function top has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      top: function( position, data ) {
                          var within = data.within,
                              withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
                              outerHeight = data.within.height,
                              collisionPosTop = position.top - data.collisionPosition.marginTop,
              Severity: Minor
              Found in assets/jquery-ui.js - About 1 hr to fix

                Method getControllerFiles has 27 lines of code (exceeds 25 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

                  Method save has 27 lines of code (exceeds 25 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

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

                        public function getItems()
                        {
                            $manager = Configs::authManager();
                            $advanced = Configs::instance()->advanced;
                            $available = [];
                    Severity: Minor
                    Found in models/AuthItem.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

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

                        protected static function filterRecursive($items, $user)
                        {
                            $result = [];
                            foreach ($items as $i => $item) {
                                $url = ArrayHelper::getValue($item, 'url', '#');
                    Severity: Minor
                    Found in components/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

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

                                    atOffset = data.at[ 0 ] === "left" ?
                                        data.targetWidth :
                                        data.at[ 0 ] === "right" ?
                                            -data.targetWidth :
                                            0,
                    Severity: Minor
                    Found in assets/jquery-ui.js and 1 other location - About 50 mins to fix
                    assets/jquery-ui.js on lines 1289..1293

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

                    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

                                    atOffset = data.at[ 1 ] === "top" ?
                                        data.targetHeight :
                                        data.at[ 1 ] === "bottom" ?
                                            -data.targetHeight :
                                            0,
                    Severity: Minor
                    Found in assets/jquery-ui.js and 1 other location - About 50 mins to fix
                    assets/jquery-ui.js on lines 1254..1258

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

                    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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function save()
                        {
                            if ($this->validate()) {
                                $manager = Configs::authManager();
                                $class = $this->className;
                    Severity: Minor
                    Found in models/BizRule.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

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

                        public function actionAssign($id)
                        {
                            $items = Yii::$app->getRequest()->post('items', []);
                            $model = new Assignment($id);
                            $success = $model->assign($items);
                    Severity: Minor
                    Found in controllers/AssignmentController.php and 1 other location - About 45 mins to fix
                    controllers/AssignmentController.php on lines 116..123

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

                    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 actionRevoke($id)
                        {
                            $items = Yii::$app->getRequest()->post('items', []);
                            $model = new Assignment($id);
                            $success = $model->revoke($items);
                    Severity: Minor
                    Found in controllers/AssignmentController.php and 1 other location - About 45 mins to fix
                    controllers/AssignmentController.php on lines 102..109

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

                    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 actionRemove($id)
                        {
                            $items = Yii::$app->getRequest()->post('items', []);
                            $model = $this->findModel($id);
                            $success = $model->removeChildren($items);
                    Severity: Minor
                    Found in components/ItemController.php and 1 other location - About 40 mins to fix
                    components/ItemController.php on lines 122..130

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

                    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 actionAssign($id)
                        {
                            $items = Yii::$app->getRequest()->post('items', []);
                            $model = $this->findModel($id);
                            $success = $model->addChildren($items);
                    Severity: Minor
                    Found in components/ItemController.php and 1 other location - About 40 mins to fix
                    components/ItemController.php on lines 151..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 94.

                    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

                    Consider simplifying this complex logical expression.
                    Open

                                if (term == '' || menu.name.toLowerCase().indexOf(term) >= 0 ||
                                    (menu.parent_name && menu.parent_name.toLowerCase().indexOf(term) >= 0) ||
                                    (menu.route && menu.route.toLowerCase().indexOf(term) >= 0)) {
                                    result.push(menu);
                                    limit--;
                    Severity: Major
                    Found in views/menu/_script.js - About 40 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language