bizley/yii2-podium

View on GitHub
src/maintenance/SchemaOperation.php

Summary

Maintainability
D
2 days
Test Coverage

The class SchemaOperation has an overall complexity of 54 which is very high. The configured complexity threshold is 50.
Open

class SchemaOperation extends Component
{
    const TYPE_SUCCESS = 0;
    const TYPE_WARNING = 1;
    const TYPE_ERROR = 2;
Severity: Minor
Found in src/maintenance/SchemaOperation.php by phpmd

File SchemaOperation.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace bizley\podium\maintenance;

use bizley\podium\Podium;
Severity: Minor
Found in src/maintenance/SchemaOperation.php - About 2 hrs to fix

    SchemaOperation has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SchemaOperation extends Component
    {
        const TYPE_SUCCESS = 0;
        const TYPE_WARNING = 1;
        const TYPE_ERROR = 2;
    Severity: Minor
    Found in src/maintenance/SchemaOperation.php - About 2 hrs to fix

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

          protected function addForeign($key, $ref, $col, $delete = null, $update = null)
      Severity: Minor
      Found in src/maintenance/SchemaOperation.php - About 35 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $this->returnError($e->getMessage(), __METHOD__,
                        Yii::t('podium/flash', 'Error during table foreign key {name} adding', [
                            'name' => $this->getForeignName($key)
                        ])
                    );
        Severity: Major
        Found in src/maintenance/SchemaOperation.php - About 30 mins to fix

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

              protected function addColumn($col, $type)
              {
                  if (empty($col)) {
                      return Yii::t('podium/flash', 'Installation aborted! Column name missing.');
                  }
          Severity: Major
          Found in src/maintenance/SchemaOperation.php and 1 other location - About 3 hrs to fix
          src/maintenance/SchemaOperation.php on lines 166..182

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

          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

              protected function alterColumn($col, $type)
              {
                  if (empty($col)) {
                      return Yii::t('podium/flash', 'Installation aborted! Column name missing.');
                  }
          Severity: Major
          Found in src/maintenance/SchemaOperation.php and 1 other location - About 3 hrs to fix
          src/maintenance/SchemaOperation.php on lines 75..91

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

          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

              protected function dropForeign($name)
              {
                  if (empty($name)) {
                      return Yii::t('podium/flash', 'Installation aborted! Foreign key name missing.');
                  }
          Severity: Major
          Found in src/maintenance/SchemaOperation.php and 1 other location - About 3 hrs to fix
          src/maintenance/SchemaOperation.php on lines 279..296

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

          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

              protected function dropIndex($name)
              {
                  if (empty($name)) {
                      return Yii::t('podium/flash', 'Installation aborted! Index name missing.');
                  }
          Severity: Major
          Found in src/maintenance/SchemaOperation.php and 1 other location - About 3 hrs to fix
          src/maintenance/SchemaOperation.php on lines 255..272

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

          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