Showing 246 of 247 total issues
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)) {
- Create a ticketCreate a ticket
Method tryLoad
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
public function tryLoad(Model $model, $id): ?array
{
$model->assertIsModel();
- Create a ticketCreate a ticket
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]
- Create a ticketCreate a ticket
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,
- Create a ticketCreate a ticket
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,
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket
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,
- Create a ticketCreate a ticket
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();
}
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function getReferences(): array
{
$this->assertIsModel();
$res = [];
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 106.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function getJoins(): array
{
$this->assertIsModel();
$res = [];
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 106.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
- Read upRead up
- Create a ticketCreate a ticket
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);
- Read upRead up
- Create a ticketCreate a ticket
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();
- Read upRead up
- Create a ticketCreate a ticket
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 _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) {
- Read upRead up
- Create a ticketCreate a ticket
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;
- Read upRead up
- Create a ticketCreate a ticket
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 addField
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function addField(string $fieldName, array $defaults = []): Field
{
if (!isset($defaults['aggregate']) && !isset($defaults['concat']) && !isset($defaults['expr'])) {
throw (new Exception('Aggregate field requires "aggregate", "concat" or "expr" specified to hasMany()->addField()'))
->addMoreInfo('field', $fieldName)
- Read upRead up
- Create a ticketCreate a ticket
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 setGroupBy
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function setGroupBy(array $fields, array $aggregateExpressions = [])
{
foreach ($fields as $fieldName) {
if ($fieldName instanceof Expression || $this->hasField($fieldName)) {
continue;
- Read upRead up
- Create a ticketCreate a ticket
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 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'();
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
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]
- Create a ticketCreate a ticket