File QueryBuilder.php
has 1254 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* MIT License. This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
QueryBuilder
has 59 functions (exceeds 20 allowed). Consider refactoring. Open
class QueryBuilder extends AbstractOMBuilder
{
/**
* Returns the package for the [base] object classes.
*
Method addFilterByCol
has 139 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFilterByCol(string &$script, Column $col): void
{
$colPhpName = $col->getPhpName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
Method addFindPkSimple
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFindPkSimple(string &$script): void
{
$table = $this->getTable();
// this method is not needed if the table has no primary key
Function addFilterByCol
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function addFilterByCol(string &$script, Column $col): void
{
$colPhpName = $col->getPhpName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
- 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 addClassBody
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addClassBody(string &$script): void
{
$table = $this->getTable();
// namespaces
Function addFindPkSimple
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
protected function addFindPkSimple(string &$script): void
{
$table = $this->getTable();
// this method is not needed if the table has no primary key
- 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 addFilterByFk
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFilterByFk(string &$script, ForeignKey $fk): void
{
$this->declareClasses(
'\Propel\Runtime\Collection\ObjectCollection',
'\Propel\Runtime\Exception\PropelException',
Method addFilterByRefFk
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFilterByRefFk(string &$script, ForeignKey $fk): void
{
$this->declareClasses(
'\Propel\Runtime\Collection\ObjectCollection',
'\Propel\Runtime\Exception\PropelException',
Method addFilterByPrimaryKeys
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFilterByPrimaryKeys(string &$script): void
{
$script .= "
/**
* Filter the query by a list of primary keys
Method addFindPk
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFindPk(string &$script): void
{
$class = $this->getObjectClassName();
$tableMapClassName = $this->getTableMapClassName();
$table = $this->getTable();
Function addClassBody
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function addClassBody(string &$script): void
{
$table = $this->getTable();
// namespaces
- 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 addPrune
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addPrune(string &$script): void
{
$table = $this->getTable();
$class = $this->getObjectClassName();
$objectName = '$' . $table->getCamelCaseName();
Method addDoOnDeleteCascade
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addDoOnDeleteCascade(string &$script): void
{
$table = $this->getTable();
$script .= "
/**
Method addDoOnDeleteSetNull
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addDoOnDeleteSetNull(string &$script): void
{
$table = $this->getTable();
$script .= "
/**
Method addDelete
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addDelete(string &$script): void
{
$script .= "
/**
* Performs a DELETE on the database based on the current ModelCriteria
Method addFilterByPrimaryKey
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFilterByPrimaryKey(string &$script): void
{
$script .= "
/**
* Filter the query by primary key
Method addFindPks
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFindPks(string &$script): void
{
$this->declareClasses(
'\Propel\Runtime\Collection\Collection',
'\Propel\Runtime\Connection\ConnectionInterface',
Method addFilterByArrayCol
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFilterByArrayCol(string &$script, Column $col): void
{
$singularPhpName = $col->getPhpSingularName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
Function addDoOnDeleteSetNull
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function addDoOnDeleteSetNull(string &$script): void
{
$table = $this->getTable();
$script .= "
/**
- 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 addDoOnDeleteCascade
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function addDoOnDeleteCascade(string &$script): void
{
$table = $this->getTable();
$script .= "
/**
- 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 addFilterByFk
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function addFilterByFk(string &$script, ForeignKey $fk): void
{
$this->declareClasses(
'\Propel\Runtime\Collection\ObjectCollection',
'\Propel\Runtime\Exception\PropelException',
- 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 isDeleteCascadeEmulationNeeded
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function isDeleteCascadeEmulationNeeded(): bool
{
$table = $this->getTable();
if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
foreach ($table->getReferrers() as $fk) {
- 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 isDeleteSetNullEmulationNeeded
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function isDeleteSetNullEmulationNeeded(): bool
{
$table = $this->getTable();
if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
foreach ($table->getReferrers() as $fk) {
- 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 addFilterByPrimaryKeys
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function addFilterByPrimaryKeys(string &$script): void
{
$script .= "
/**
* Filter the query by a list of primary keys
- 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 addUseRelatedQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function addUseRelatedQuery(string &$script, Table $fkTable, string $queryClass, string $relationName, string $joinType): void
Method addWithRelatedQuery
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function addWithRelatedQuery(string &$script, Table $fkTable, string $queryClass, string $relationName, string $joinType): void
Method addJoinRelated
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string &$script,
Table $fkTable,
string $queryClass,
string $relationName,
string $joinType
Function addFindPk
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function addFindPk(string &$script): void
{
$class = $this->getObjectClassName();
$tableMapClassName = $this->getTableMapClassName();
$table = $this->getTable();
- 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 addFilterByRefFk
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function addFilterByRefFk(string &$script, ForeignKey $fk): void
{
$this->declareClasses(
'\Propel\Runtime\Collection\ObjectCollection',
'\Propel\Runtime\Exception\PropelException',
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function isDeleteCascadeEmulationNeeded(): bool
{
$table = $this->getTable();
if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
foreach ($table->getReferrers() as $fk) {
- 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 91.
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
protected function isDeleteSetNullEmulationNeeded(): bool
{
$table = $this->getTable();
if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
foreach ($table->getReferrers() as $fk) {
- 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 91.
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