mdmsoft/yii2-admin

View on GitHub

Showing 114 of 114 total issues

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

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

        if ( options.my[ 0 ] === "right" ) {
            position.left -= elemWidth;
        } else if ( options.my[ 0 ] === "center" ) {
            position.left -= elemWidth / 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 1080..1084

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

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

    if ( options.at[ 1 ] === "bottom" ) {
        basePosition.top += targetHeight;
    } else if ( options.at[ 1 ] === "center" ) {
        basePosition.top += targetHeight / 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 1074..1078
assets/jquery-ui.js on lines 1080..1084

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

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

<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
Severity: Major
Found in views/menu/create.php and 1 other location - About 1 hr to fix
views/rule/create.php on lines 1..22

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

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

<?php

use yii\helpers\Html;

/* @var $this  yii\web\View */
Severity: Major
Found in views/rule/create.php and 1 other location - About 1 hr to fix
views/menu/create.php on lines 1..22

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

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

    private static function normalizeMenu(&$assigned, &$menus, $callback, $parent = null)
    {
        $result = [];
        $order = [];
        foreach ($assigned as $id) {
Severity: Minor
Found in components/MenuHelper.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 addNew has a Cognitive Complexity of 12 (exceeds 5 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

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

    public static function checkRoute($route, $params = [], $user = null)
    {
        $config = Configs::instance();
        $r = static::normalizeRoute($route, $config->advanced);
        if ($config->onlyRegisteredRoute && !isset(static::getRegisteredRoutes()[$r])) {
Severity: Minor
Found in components/Helper.php - About 1 hr to fix

    Method getMenus has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getMenus()
        {
            if ($this->_normalizeMenus === null) {
                $mid = '/' . $this->getUniqueId() . '/';
                // resolve core menus
    Severity: Minor
    Found in Module.php - About 1 hr to fix

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

      function updateRoutes(r) {
          _opts.routes.available = r.available;
          _opts.routes.assigned = r.assigned;
          search('available');
          search('assigned');
      Severity: Major
      Found in views/route/_script.js and 2 other locations - About 1 hr to fix
      views/assignment/_script.js on lines 2..7
      views/item/_script.js on lines 2..7

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

      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

      function updateItems(r) {
          _opts.items.available = r.available;
          _opts.items.assigned = r.assigned;
          search('available');
          search('assigned');
      Severity: Major
      Found in views/assignment/_script.js and 2 other locations - About 1 hr to fix
      views/item/_script.js on lines 2..7
      views/route/_script.js on lines 2..7

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

      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

      function updateItems(r) {
          _opts.items.available = r.available;
          _opts.items.assigned = r.assigned;
          search('available');
          search('assigned');
      Severity: Major
      Found in views/item/_script.js and 2 other locations - About 1 hr to fix
      views/assignment/_script.js on lines 2..7
      views/route/_script.js on lines 2..7

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

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

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

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

          Function removeChildren has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function removeChildren($items)
              {
                  $manager = Configs::authManager();
                  $success = 0;
                  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 addChildren has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function addChildren($items)
              {
                  $manager = Configs::authManager();
                  $success = 0;
                  if ($this->_item) {
          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 left has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Function option has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                option: function( key, value ) {
                    var options = key,
                        parts,
                        curOption,
                        i;
            Severity: Minor
            Found in assets/jquery-ui.js - About 1 hr to fix

              Method search has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function search($params)
                  {
                      $query = MenuModel::find()
                          ->from(MenuModel::tableName() . ' t')
                          ->joinWith(['menuParent' => function ($q) {
              Severity: Minor
              Found in models/searchs/Menu.php - About 1 hr to fix

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

                        if ($this->_item) {
                            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 227..240

                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

                Severity
                Category
                Status
                Source
                Language