Showing 228 of 247 total issues

Model has 91 functions (exceeds 20 allowed). Consider refactoring.
Open

class Model implements \IteratorAggregate
{
    use CollectionTrait {
        _addIntoCollection as private __addIntoCollection;
    }
Severity: Major
Found in src/Model.php - About 1 day to fix

File Query.php has 731 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Data\Persistence\Sql;
Severity: Major
Found in src/Persistence/Sql/Query.php - About 1 day to fix

File Sql.php has 541 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Data\Persistence;
Severity: Major
Found in src/Persistence/Sql.php - About 1 day to fix

File Expression.php has 512 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Data\Persistence\Sql;
Severity: Major
Found in src/Persistence/Sql/Expression.php - About 1 day to fix

Query has 54 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Query extends Expression
{
    private const FIELD_INT_STRING_PREFIX = "\xff_int-string_";

    /** Template name for render. */
Severity: Major
Found in src/Persistence/Sql/Query.php - About 7 hrs to fix

Function __construct has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct(array $data = [])
    {
        if (count($data) > 0 && !is_array(reset($data))) {
            $dataOrig = $data;
            $data = [];
Severity: Minor
Found in src/Persistence/Static_.php - About 6 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 setDb has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function setDb(array $dbData, bool $importData = true): void
    {
        foreach ($dbData as $tableName => $data) {
            $idField = $data['_types']['_idField'] ?? 'id';
            unset($data['_types']['_idField']);
Severity: Minor
Found in src/Schema/TestCase.php - About 6 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 toQueryArguments has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function toQueryArguments(): array
    {
        $field = $this->field;
        $operator = $this->operator;
        $value = $this->value;
Severity: Minor
Found in src/Model/Scope/Condition.php - About 6 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

File Migrator.php has 429 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Data\Schema;
Severity: Minor
Found in src/Schema/Migrator.php - About 6 hrs to fix

Function compareExportUnorderedValue has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    private static function compareExportUnorderedValue($a, $b): int
    {
        if ($a === $b) {
            return 0;
        }
Severity: Minor
Found in src/Schema/TestCase.php - About 6 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 normalizeDsn has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public static function normalizeDsn($dsn, $user = null, $password = null)
    {
        // BC for 2.4 - 3.0 accepted DSN input
        if (is_string($dsn)) {
            $dsn = ['dsn' => $dsn];
Severity: Minor
Found in src/Persistence/Sql/Connection.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 normalize has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function normalize($value)
    {
        try {
            if ($this->issetOwner() && $this->getOwner()->hook(Model::HOOK_NORMALIZE, [$this, $value]) === false) {
                return $value;
Severity: Minor
Found in src/Field.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 export has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    public function export(?array $fields = null, ?string $keyField = null, bool $typecast = true): array
    {
        $this->assertHasPersistence('export');

        // no key field - then just do export
Severity: Minor
Found in src/Model.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 _subrenderCondition has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _subrenderCondition(array $row): string
    {
        if (count($row) === 1) {
            [$field] = $row;
        } elseif (count($row) === 3) {
Severity: Minor
Found in src/Persistence/Sql/Query.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 _copy has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _copy(Model $source, Model $destination, array $references, array $exclusions, array $transforms): Model
    {
        try {
            $sourceTable = $source->getModel()->table;

Severity: Minor
Found in src/Util/DeepCopy.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 _execute has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _execute(?object $connection, bool $fromExecuteStatement)
    {
        if ($connection === null) {
            $connection = $this->connection;
        }
Severity: Minor
Found in src/Persistence/Sql/Expression.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

File Join.php has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Data\Model;
Severity: Minor
Found in src/Model/Join.php - About 4 hrs to fix

File Persistence.php has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Data;
Severity: Minor
Found in src/Persistence.php - About 4 hrs to fix

Function _typecastPreField has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    private function _typecastPreField(Field $field, $value, bool $fromLoad)
    {
        if (is_string($value)) {
            switch ($field->type) {
                case 'boolean':
Severity: Minor
Found in src/Persistence.php - About 4 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

Consider simplifying this complex logical expression.
Open

                if ($matches[3] === 'BOOLEAN' && ($types[$k] === ParameterType::BOOLEAN || $types[$k] === ParameterType::INTEGER)
                    && (is_bool($params[$k]) || $params[$k] === '0' || $params[$k] === '1')
                ) {
                    $types[$k] = ParameterType::BOOLEAN;
                    $params[$k] = (bool) $params[$k];
Severity: Critical
Found in src/Schema/TestCase.php - About 4 hrs to fix
Severity
Category
Status
Source
Language