Showing 228 of 247 total issues

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

    protected function _renderTable($addAlias = true): ?string
    {
        $res = [];
        foreach ($this->args['table'] ?? [] as $alias => $table) {
            if ($addAlias === false && $table instanceof self) {
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 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 makeHashFromKey has a Cognitive Complexity of 11 (exceeds 5 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

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 tryLoad has a Cognitive Complexity of 11 (exceeds 5 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

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 set has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function set(string $field, $value)
    {
        $this->getModel()->assertOnlyField($field);

        $f = $this->getField($field);
Severity: Minor
Found in src/Model.php - About 1 hr to fix

Method where has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function where($field, $operator = null, $value = null, $kind = 'where', $numArgs = null)
    {
        // number of passed arguments will be used to determine if arguments were specified or not
        if ($numArgs === null) {
            $numArgs = 'func_num_args'();
Severity: Minor
Found in src/Persistence/Sql/Query.php - About 1 hr to fix

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

    #[\Override]
    public function wrap(Driver $driver): Driver
    {
        return new class($driver) extends AbstractDriverMiddleware {
            #[\Override]
Severity: Minor
Found in src/Persistence/Sql/Sqlite/CreateRegexpLikeFunctionMiddleware.php - About 1 hr to fix

Method _subrenderCondition has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    protected function _subrenderCondition(array $row): string
    {
        if (count($row) !== 1) {
            [$field, $operator, $value] = $row;
Severity: Minor
Found in src/Persistence/Sql/Oracle/Query.php - About 1 hr to fix

Method createForeignKey has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createForeignKey($relation): void
    {
        [$localField, $foreignField] = is_array($relation)
            ? $relation
            : $this->resolveRelationDirection($relation);
Severity: Minor
Found in src/Schema/Migrator.php - About 1 hr to fix

Method initQueryFields has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function initQueryFields(Model $model, Query $query, ?array $fields = null): void
    {
        // init fields
        if ($fields !== null) {
            // set of fields is strictly defined, so we will ignore even system fields
Severity: Minor
Found in src/Persistence/Sql.php - About 1 hr to fix

Method escapeStringLiteral has 30 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/Postgresql/ExpressionTrait.php - About 1 hr to fix

Method ref has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    public function ref(Model $ourModelOrEntity, array $defaults = []): Model
    {
        $this->assertOurModelOrEntity($ourModelOrEntity);

Severity: Minor
Found in src/Reference/ContainsOne.php - About 1 hr to fix

Method action has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    public function action(string $mode, array $args = [])
    {
        switch ($mode) {
            case 'select':
Severity: Minor
Found in src/Model/AggregateModel.php - About 1 hr to fix

Method _renderCase has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _renderCase(): ?string
    {
        if (!isset($this->args['case_when'])) {
            return null;
        }
Severity: Minor
Found in src/Persistence/Sql/Query.php - About 1 hr to fix

Method validateBeforeExecute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function validateBeforeExecute(): void
    {
        if ($this->enabled === false || ($this->enabled instanceof \Closure && ($this->enabled)($this->_getOwner()) === false)) {
            throw new Exception('User action is disabled');
        }
Severity: Minor
Found in src/Model/UserAction.php - About 1 hr to fix

Method getConnection has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    #[\Override]
    public function getConnection(): Persistence\Sql\Connection
    {
        \Closure::bind(function () {
            if (($this->_connection ?? null) === null) {
Severity: Minor
Found in src/Schema/TestSqlPersistence.php - About 1 hr to fix

Method init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in src/Reference/ContainsBase.php - About 1 hr to fix

Method setOrder has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setOrder($field, string $direction = 'asc')
    {
        $this->assertIsModel();

        // fields passed as array
Severity: Minor
Found in src/Model.php - About 1 hr to fix

Method fieldToWords has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function fieldToWords(Model $model): string
    {
        $words = [];

        $field = $this->field;
Severity: Minor
Found in src/Model/Scope/Condition.php - About 1 hr to fix

Method _typecastLoadField has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _typecastLoadField(Field $field, $value)
    {
        $value = $this->_typecastPreField($field, $value, true);

        // native DBAL DT types have no microseconds support
Severity: Minor
Found in src/Persistence.php - About 1 hr to fix
Severity
Category
Status
Source
Language