mheinzerling/php-databaseutils

View on GitHub

Showing 28 of 115 total issues

Function migrate has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    public function migrate(Migration $migration, Table $before, SqlSetting $setting): void
    {
        //TODO rename
        $meta = [];
        if ($this->engine != $before->engine) $meta[] = "ENGINE=" . $this->engine;
Severity: Minor
Found in src/structure/Table.php - About 5 hrs 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 importDump has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function importDump(\PDO $pdo, string $sqlFile): bool
    {
        $content = file_get_contents($sqlFile);
        $queries = explode(";\n", str_replace("\r", "", $content));
        $pdo->beginTransaction();
Severity: Minor
Found in src/DatabaseUtils.php - About 2 hrs 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 migrate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function migrate(Migration $migration, Table $before, SqlSetting $setting): void
    {
        //TODO rename
        $meta = [];
        if ($this->engine != $before->engine) $meta[] = "ENGINE=" . $this->engine;
Severity: Minor
Found in src/structure/Table.php - About 1 hr to fix

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

        public function resolveLazyIndexes(): void
        {
            foreach ($this->indexes as &$index) {
                if (StringUtils::contains(get_class($index), "lazy")) {
                    if ($index instanceof LazyIndex || $index instanceof LazyUnique) {
    Severity: Minor
    Found in src/structure/Table.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 migrate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function migrate(Database $before, SqlSetting $setting, array $renames = null /*TODO*/): Migration
        {
            $migration = new Migration();
            if ($this->name != $before->name) $migration->todo("TODO: rename database to >" . $this->name . "< from >" . $before->name . "<");
            $myTables = $this->topoOrder($this->getTables());
    Severity: Minor
    Found in src/structure/Database.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 complete has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function complete(): DatabaseBuilder
        {
            $this->table->init($this->engine != null ? $this->engine : $this->db->getDefaultEngine(),
                $this->charset != null ? $this->charset : $this->db->getDefaultCharset(),
                $this->collation != null ? $this->collation : $this->db->getDefaultCollation(),
    Severity: Minor
    Found in src/structure/builder/TableBuilder.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 toCreateSql has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function toCreateSql(SqlSetting $setting): string
        {
            $delimiter = $setting->singleLine ? " " : "\n";
            $sql = 'CREATE TABLE ';
            if ($setting->createTableIfNotExists) $sql .= 'IF NOT EXISTS ';
    Severity: Minor
    Found in src/structure/Table.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 fromSql has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function fromSql(TableBuilder $tb, string $constraint): void
        {
            //TODO more robust
            if (StringUtils::contains($constraint, "FOREIGN KEY", true)) {
                $onUpdate = ReferenceOption::memberByValueWithDefault(StringUtils::findAndRemove($constraint, "@ON UPDATE (RESTRICT|CASCADE|SET NULL|NO ACTION)@i"), null);
    Severity: Minor
    Found in src/structure/index/Index.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 modifySql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function modifySql(Field $before, SqlSetting $setting): ?string
        {
            //TODO rename
            $ta = $this->type;
            $tb = $before->type;
    Severity: Minor
    Found in src/structure/Field.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 fromDatabase has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function fromDatabase(\PDO $pdo, DatabaseBuilder $db, string $tableName, string $engine, string $collation, string $currentAutoincrement = null, array $booleanFields = []): void
        {
            $tb = $db->table($tableName)->engine($engine)->charset(explode("_", $collation, 2)[0])->collation($collation)->autoincrement(intval($currentAutoincrement));
    
    
    
    Severity: Minor
    Found in src/structure/builder/TableBuilder.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 topoOrder has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function topoOrder(array $tables): array
        {
            $result = [];
            while (count($tables)) {
                $added = false;
    Severity: Minor
    Found in src/structure/Database.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

    Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct(string $tableName, array $fieldNames, string $name = null, string $referenceTableName, array $referenceFields, ReferenceOption $onUpdate, ReferenceOption $onDelete)
    Severity: Major
    Found in src/structure/index/LazyForeignKey.php - About 50 mins to fix

      Method fromDatabase has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function fromDatabase(\PDO $pdo, DatabaseBuilder $db, string $tableName, string $engine, string $collation, string $currentAutoincrement = null, array $booleanFields = []): void
      Severity: Major
      Found in src/structure/builder/TableBuilder.php - About 50 mins to fix

        Method foreign has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function foreign(array $fields, string $referenceTable, array $referenceFields, ReferenceOption $onUpdate, ReferenceOption $onDelete, string $name = null): TableBuilder
        Severity: Minor
        Found in src/structure/builder/TableBuilder.php - About 45 mins to fix

          Function toBuilderCode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function toBuilderCode(): string
              {
                  $result = "\n    ->table(\"" . $this->name . "\")";
                  foreach ($this->indexes as $index) {
                      $result .= $index->toBuilderCode();
          Severity: Minor
          Found in src/structure/Table.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

          Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function __construct(array $fields = null, string $name = null, Table &$referenceTable = null, array $referenceFields, ReferenceOption $onUpdate, ReferenceOption $onDelete)
          Severity: Minor
          Found in src/structure/index/ForeignKey.php - About 45 mins to fix

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

                public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null)
            Severity: Minor
            Found in src/logging/LoggingPDOStatement.php - About 35 mins to fix

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

                  public function bindParam($parameter, &$variable, $data_type = \PDO::PARAM_STR, $length = null, $driver_options = null)
              Severity: Minor
              Found in src/logging/LoggingPDOStatement.php - About 35 mins to fix

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

                    private static function onDuplicateAndExec(\PDO $pdo, int $onDuplicate, array $keys, string $sql, array $params): int
                Severity: Minor
                Found in src/DatabaseUtils.php - About 35 mins to fix

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

                      public function foreign(string $name = null, string $table, string $reference, ReferenceOption $onUpdate, ReferenceOption $onDelete): FieldBuilder
                  Severity: Minor
                  Found in src/structure/builder/FieldBuilder.php - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language