src/Schema/TestCase.php

Summary

Maintainability
F
4 days
Test Coverage

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

    public function setDb(array $dbData, bool $importData = true): void
    {
        foreach ($dbData as $tableName => $data) {
            $migrator = $this->createMigrator()->table($tableName);

Severity: Minor
Found in src/Schema/TestCase.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

File TestCase.php has 365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

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

Function getDb has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDb(?array $tableNames = null, bool $noId = false): array
    {
        if ($tableNames === null) {
            $tableNames = [];
            foreach ($this->createdMigrators as $migrator) {
Severity: Minor
Found in src/Schema/TestCase.php - About 3 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 3 hrs to fix

Method logQuery has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function logQuery(string $sql, array $params, array $types): void
    {
        if (!$this->debug) {
            return;
        }
Severity: Major
Found in src/Schema/TestCase.php - About 2 hrs to fix

Method setDb has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setDb(array $dbData, bool $importData = true): void
    {
        foreach ($dbData as $tableName => $data) {
            $migrator = $this->createMigrator()->table($tableName);

Severity: Major
Found in src/Schema/TestCase.php - About 2 hrs to fix

Method compareExportUnorderedValue has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function compareExportUnorderedValue($a, $b): int
    {
        if ($a === $b) {
            return 0;
        }
Severity: Major
Found in src/Schema/TestCase.php - About 2 hrs to fix

Method getDb has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getDb(?array $tableNames = null, bool $noId = false): array
    {
        if ($tableNames === null) {
            $tableNames = [];
            foreach ($this->createdMigrators as $migrator) {
Severity: Minor
Found in src/Schema/TestCase.php - About 1 hr to fix

Avoid too many return statements within this method.
Open

                        return $cmp;
Severity: Major
Found in src/Schema/TestCase.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 0;
Severity: Major
Found in src/Schema/TestCase.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return $matches[4] ?? $matches[2];
Severity: Major
Found in src/Schema/TestCase.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return $matches[4] ?? $matches[2];
Severity: Major
Found in src/Schema/TestCase.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return $convertedSql;
Severity: Major
Found in src/Schema/TestCase.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return $a <=> $b;
Severity: Major
Found in src/Schema/TestCase.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return $matches[0];
Severity: Major
Found in src/Schema/TestCase.php - About 30 mins to fix

Function tearDown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    #[\Override]
    protected function tearDown(): void
    {
        $debugOrig = $this->debug;
        try {
Severity: Minor
Found in src/Schema/TestCase.php - About 25 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

There are no issues that match your filters.

Category
Status