Showing 228 of 247 total issues

Function _renderField has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _renderField($addAlias = true): string
    {
        // if no fields were defined, use defaultField
        if (($this->args['field'] ?? []) === []) {
            if ($this->defaultField instanceof Expression) {
Severity: Minor
Found in src/Persistence/Sql/Query.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 order has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function order($order, $direction = null)
    {
        if (is_string($order) && str_contains($order, ',')) {
            throw new Exception('Comma-separated fields list is no longer accepted, use array instead');
        }
Severity: Minor
Found in src/Persistence/Sql/Query.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 _load has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function _load(bool $fromReload, bool $fromTryLoad, $id)
    {
        $this->getModel()->assertHasPersistence();
        if ($this->isLoaded()) {
            throw new Exception('Entity must be unloaded');
Severity: Minor
Found in src/Model.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 init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    #[\Override]
    protected function init(): void
    {
        parent::init();

Severity: Minor
Found in src/Reference/HasOne.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 isIndexExists has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function isIndexExists(array $fields, bool $requireUnique = false): bool
    {
        $fields = array_map(fn ($field) => $this->resolvePersistenceField($field), $fields);
        $tableName = reset($fields)->getOwner()->table;

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

Method consume has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function consume($expr, string $escapeMode): string
    {
        if (!is_object($expr)) {
            switch ($escapeMode) {
                case self::ESCAPE_PARAM:
Severity: Minor
Found in src/Persistence/Sql/Expression.php - About 1 hr to fix

Method escapeStringLiteral has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    protected function escapeStringLiteral(string $value): string
    {
        $dummyPersistence = (new \ReflectionClass(Persistence\Sql::class))->newInstanceWithoutConstructor();
        if (\Closure::bind(static fn () => $dummyPersistence->explicitCastIsEncodedBinary($value), null, Persistence\Sql::class)()) {
Severity: Minor
Found in src/Persistence/Sql/Mssql/ExpressionTrait.php - About 1 hr to fix

Method getColumnComment has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    protected function getColumnComment(Column $column)
    {
        $tmpType = new class extends Type {
            private Type $type;
Severity: Minor
Found in src/Persistence/Sql/PlatformFixColumnCommentTypeHintTrait.php - About 1 hr to fix

Method makeHashFromKey has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function makeHashFromKey($value, ?\HashContext $hashContext = null): ?int
    {
        if ($hashContext === null) {
            $hashContext = hash_init('crc32c');
            $return = true;
Severity: Minor
Found in src/Reference/WeakAnalysingMap.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

                if (($f === 'system' && $field->system)
                    || ($f === 'not system' && !$field->system)
                    || ($f === 'editable' && $field->isEditable())
                    || ($f === 'visible' && $field->isVisible())
                ) {
Severity: Critical
Found in src/Model.php - About 1 hr to fix

Method _renderConditionBinary has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override] // @phpstan-ignore method.childParameterType (https://github.com/phpstan/phpstan/issues/10942)
    protected function _renderConditionBinary(string $operator, string $sqlLeft, $sqlRight): string
    {
        if (in_array($operator, ['in', 'not in'], true)) {
            if (is_array($sqlRight)) {
Severity: Minor
Found in src/Persistence/Sql/Sqlite/Query.php - About 1 hr to fix

Method tryLoad has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    public function tryLoad(Model $model, $id): ?array
    {
        $model->assertIsModel();

Severity: Minor
Found in src/Persistence/Array_.php - About 1 hr to fix

Method wrap has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    public function wrap(Driver $driver): Driver
    {
        return new class($driver) extends AbstractDriverMiddleware {
            #[\Override]

Method _renderConditionBinaryReuse has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _renderConditionBinaryReuse(
        string $sqlLeft,
        string $sqlRight,
        \Closure $makeSqlFx,
        bool $allowReuseLeft = true,
Severity: Minor
Found in src/Persistence/Sql/Query.php - About 1 hr to fix

Method _renderConditionLikeOperator has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    protected function _renderConditionLikeOperator(bool $negated, string $sqlLeft, string $sqlRight): string
    {
        return ($negated ? 'not ' : '') . $this->_renderConditionBinaryReuse(
            $sqlLeft,
Severity: Minor
Found in src/Persistence/Sql/Sqlite/Query.php - About 1 hr to fix

Method match has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function match(array $row, Model\Scope\AbstractScope $condition): bool
    {
        if ($condition instanceof Model\Scope\Condition) { // simple condition
            $args = $condition->toQueryArguments();

Severity: Minor
Found in src/Persistence/Array_/Action.php - About 1 hr to fix

Method initUserActions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function initUserActions(): void
    {
        // declare our basic CRUD actions for the model
        $this->addUserAction('add', [
            'fields' => true,
Severity: Minor
Found in src/Model/UserActionsTrait.php - About 1 hr to fix

Method deduplicateAnalysingKey has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function deduplicateAnalysingKey(array $analysingKey, object $analysingOwner): array
    {
        if ((self::$analysingClosureMap ?? null) === null) {
            self::$analysingClosureMap = new WeakAnalysingMap();
        }
Severity: Minor
Found in src/Reference.php - About 1 hr to fix

Function restoreSequencesIfDecremented has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function restoreSequencesIfDecremented(array $beforeRollbackSequences): void
    {
        $afterRollbackSequences = $this->listSequences();

        foreach ($beforeRollbackSequences as $schema => $beforeRollbackSequences2) {

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

    private function saveRow(Model $model, array $rowData, $id): void
    {
        if ($model->idField) {
            $idField = $model->getIdField();
            $id = $idField->normalize($id);
Severity: Minor
Found in src/Persistence/Array_.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

Severity
Category
Status
Source
Language