mheinzerling/php-databaseutils

View on GitHub

Showing 28 of 115 total issues

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

    public static function insertMultiple(\PDO $pdo, string $table, array $keys, array $datas, int $onDuplicate = self::DUPLICATE_FAIL): int
Severity: Minor
Found in src/DatabaseUtils.php - About 35 mins to fix

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

        public function hasForeignKeysOnlyOn(array $tables): bool
        {
            if (empty($this->indexes)) return true;
            $names = array_keys($tables);
            foreach ($this->indexes as $index) {
    Severity: Minor
    Found in src/structure/Table.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 fromSql has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function fromSql(string $type, string $collation = null, bool $isBoolean = false): Type
        {
            //TODO register parser
            $result = BoolType::parseBool($type);
            if ($result != null) return $result;
    Severity: Minor
    Found in src/structure/type/Type.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 toSql has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function toSql(SqlSetting $setting): string
        {
            $sql = '`' . $this->name . '` ';
            $sql .= $this->type->toSql() . ' ';
            if (!$this->null) $sql .= "NOT NULL ";
    Severity: Minor
    Found in src/structure/Field.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 fromSqlCreate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function fromSqlCreate(DatabaseBuilder $db, string $sql): void
        {
            list($tableName, $remaining) = explode('(', $sql, 2);
            $tableName = trim(str_replace(["CREATE TABLE", "IF NOT EXISTS", "`"], "", $tableName));
            $tb = $db->table($tableName);
    Severity: Minor
    Found in src/structure/builder/TableBuilder.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

            if ($result != null) return $result;
    Severity: Major
    Found in src/structure/type/Type.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              if ($result != null) return $result;
      Severity: Major
      Found in src/structure/type/Type.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                if ($result != null) return $result;
        Severity: Major
        Found in src/structure/type/Type.php - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language