luyadev/luya-module-cms

View on GitHub

Showing 326 of 326 total issues

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

        $scope.aliasSuggestion = function() {
            
            $scope.itemSelection.alias = $filter('slugify')($scope.itemSelection.title);
        };
Severity: Minor
Found in src/admin/resources/js/cmsadmin.js and 1 other location - About 35 mins to fix
src/admin/resources/js/cmsadmin.js on lines 226..228

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

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

    public static function checkDuplicateAlias($currentNavId, $parentNavId)
    {
        $currentNavItems = NavItem::find()->where(['nav_id' => $currentNavId])->asArray()->all();
        foreach (self::find()->where(['parent_nav_id' => $parentNavId, 'is_deleted' => false])->andWhere(['<>', 'id', $currentNavId])->asArray()->all() as $item) {
            foreach ($currentNavItems as $currentNavItem) {
Severity: Minor
Found in src/models/Nav.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

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

    public function actionDelete($navId)
    {
        if (!Yii::$app->adminuser->canRoute(Module::ROUTE_PAGE_DELETE)) {
            throw new ForbiddenHttpException("Unable to remove this page due to permission restrictions.");
        }
Severity: Minor
Found in src/admin/apis/NavController.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

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

    public function parse($value, $sub)
    {
        $page = Nav::findOne(['id' => $value]);

        // verify if the page is of type content
Severity: Minor
Found in src/tags/PageTag.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

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

    public static function copyBlocks($fromPageId, $toPageId)
    {
        $pageBlocks = NavItemPageBlockItem::find()->where(['nav_item_page_id' => $fromPageId])->asArray(true)->all();

        $idLink = [];
Severity: Minor
Found in src/models/NavItemPage.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

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

    public static function checkUserWebsitePermissions(array $website)
    {
        /** @var User $user */
        $user = Yii::$app->adminuser->identity;
        $userGroupIds = ArrayHelper::getColumn($user->groups, 'id');
Severity: Minor
Found in src/admin/helpers/MenuHelper.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

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

    protected function saveBlock($fullClassName)
    {
        // ensure all classes start with trailing slash class name definition like `\foo\bar\Class`
        $fullClassName = '\\'  . ltrim($fullClassName, '\\');
        $model = Block::find()->where(['class' => $fullClassName])->one();
Severity: Minor
Found in src/admin/importers/BlockImporter.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

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

    public function actionIndex($itemId, $version = false, $date = false): \yii\web\Response|string
    {
        if (Yii::$app->adminuser->isGuest) {
            throw new ForbiddenHttpException('Unable to see the preview page, session expired or not logged in.');
        }
Severity: Minor
Found in src/frontend/controllers/PreviewController.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

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

    public function getType(): \luya\cms\models\NavItemPage|\luya\cms\models\NavItemModule|\luya\cms\models\NavItemRedirect|bool
    {
        if ($this->_type === null) {
            // what kind of item type are we looking for
            if ($this->nav_item_type == self::TYPE_PAGE) {
Severity: Minor
Found in src/models/NavItem.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

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

    public function getConfigPlaceholdersExport()
    {
        $array = array_key_exists('placeholders', $this->config()) ? $this->config()['placeholders'] : [];

        $holders = [];
Severity: Minor
Found in src/base/InternalBaseBlock.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

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

   set: function(name, value, days)
   {
      var domain, domainParts, date, expires, host;

      if (days) {
Severity: Minor
Found in src/frontend/views/inline/toolbar.js - 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

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

    public static function navGroupInheritanceNode($navId, Group $group)
    {
        // default defintion is false
        $definition = false;
        // see if permission data for group exists, foreach items and set if match
Severity: Minor
Found in src/admin/helpers/MenuHelper.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

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

    public function actionClasses()
    {
        if (Config::has('rc1_block_classes_renameing')) {
            return $this->outputError("You already have run the classes updater, so your system should be up-to-date already.");
        }
Severity: Minor
Found in src/frontend/commands/UpdaterController.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

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

    public function testContainerSelector()
    {
        Yii::$app->composition['langShortCode'] = 'fr';
        Yii::$app->menu->setLanguageContainer('fr', include('_dataFrArray.php'));

Severity: Minor
Found in tests/src/menu/QueryTest.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 $arr['blockName'] . " ({$arr['pageTitle']})";
Severity: Major
Found in src/models/Log.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                            return $this->sendModelError($typeModel);
    Severity: Major
    Found in src/admin/apis/NavItemController.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in src/admin/apis/NavItemController.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return true;
        Severity: Major
        Found in src/models/NavItem.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $sourceNavItem->copyTypeContent($navItem);
          Severity: Major
          Found in src/models/Nav.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                        return;
            Severity: Major
            Found in src/models/Log.php - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language