Showing 49 of 49 total issues
File Query.php
has 711 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Atk4\Dsql;
Method connectDbalConnection
has 219 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function connectDbalConnection(array $dsn)
{
if (isset($dsn['pdo'])) {
$pdo = $dsn['pdo'];
} else {
Query
has 53 functions (exceeds 20 allowed). Consider refactoring. Open
class Query extends Expression
{
/**
* Query will use one of the predefined templates. The $mode will contain
* name of template used. Basically it's part of Query property name -
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function getUpdateExtendedPropertySQL(
$name,
$value = null,
$level0Type = null,
$level0Name = null,
- Read upRead up
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 224.
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 getAddExtendedPropertySQL(
$name,
$value = null,
$level0Type = null,
$level0Name = null,
- Read upRead up
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 224.
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
File Connection.php
has 402 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Atk4\Dsql;
File Expression.php
has 393 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Atk4\Dsql;
Function execute
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function execute(object $connection = null): object
{
if ($connection === null) {
$connection = $this->connection;
}
- Read upRead up
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 _sub_render_condition
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
protected function _sub_render_condition(array $row): string
{
if (count($row) === 3) {
[$field, $cond, $value] = $row;
} elseif (count($row) === 2) {
- Read upRead up
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 join
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function join(
$foreign_table,
$master_field = null,
$join_kind = null,
$_foreign_alias = null
- Read upRead up
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
Expression
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Expression implements Expressionable, \ArrayAccess
{
/** @const string "[]" in template, escape as parameter */
protected const ESCAPE_PARAM = 'param';
/** @const string "{}" in template, escape as identifier */
Function connectDbalConnection
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected static function connectDbalConnection(array $dsn)
{
// for some reasons, the following error:
// PDOException: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12516: TNS:listener could not find available handler with matching protocol stack
// is shown randomly when a lot of connections are created in tests,
- Read upRead up
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 execute
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute(object $connection = null): object
{
if ($connection === null) {
$connection = $this->connection;
}
Method render
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render(): string
{
$hadUnderscoreParamBase = $this->_paramBase !== null;
if (!$hadUnderscoreParamBase) {
$hadUnderscoreParamBase = false;
Method where
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function where($field, $cond = null, $value = null, $kind = 'where', $num_args = null)
{
// Number of passed arguments will be used to determine if arguments were specified or not
if ($num_args === null) {
$num_args = func_num_args();
Method _sub_render_condition
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _sub_render_condition(array $row): string
{
if (count($row) === 3) {
[$field, $cond, $value] = $row;
} elseif (count($row) === 2) {
Function where
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function where($field, $cond = null, $value = null, $kind = 'where', $num_args = null)
{
// Number of passed arguments will be used to determine if arguments were specified or not
if ($num_args === null) {
$num_args = func_num_args();
- Read upRead up
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 join
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function join(
$foreign_table,
$master_field = null,
$join_kind = null,
$_foreign_alias = null
Function _render_case
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function _render_case(): ?string
{
if (!isset($this->args['case_when'])) {
return null;
}
- Read upRead up
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 getDebugQuery
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function getDebugQuery(): string
{
$result = $this->render();
foreach (array_reverse($this->params) as $key => $val) {
- Read upRead up
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"