Showing 740 of 740 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function addGetNext(string &$script): void
{
$useScope = $this->behavior->useScope();
// The generateScopePhp() method below contains the following list of variables:
// list($methodSignature, $paramsDoc, $buildScope, $buildScopeVars)
- 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 132.
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
Method hydratePropelObjectCollection
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function &hydratePropelObjectCollection(array $row): array
{
$col = 0;
// hydrate main object or take it from registry
Method addFKAccessor
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addFKAccessor(string &$script, ForeignKey $fk): void
{
$varName = $this->getFKVarName($fk);
$fkQueryBuilder = $this->getNewStubQueryBuilder($fk->getForeignTable());
$fkObjectBuilder = $this->getNewObjectBuilder($fk->getForeignTable())->getStubObjectBuilder();
Method getReverseDiff
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getReverseDiff(): self
{
$diff = new self();
// tables
CollectionIterator
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class CollectionIterator extends ArrayIterator implements IteratorInterface
{
/**
* @var \Propel\Runtime\Collection\Collection
*/
OraclePlatform
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class OraclePlatform extends DefaultPlatform
{
/**
* Initializes db specific domain mapping.
*
Method addColumns
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addColumns(Table $table): void
{
$tableName = $table->getName();
/** @var \PDOStatement $stmt */
Method addLazyLoaderBody
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addLazyLoaderBody(string &$script, Column $column): void
{
$platform = $this->getPlatform();
$clo = $column->getLowercasedName();
Method addClassBody
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addClassBody(string &$script): void
{
$table = $this->getTable();
// namespaces
Method setupObject
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setupObject(): void
{
try {
$database = $this->getDatabase();
$platform = ($this->hasPlatform()) ? $this->getPlatform() : null;
File ObjectCollection.php
has 269 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
Function arrayToDOM
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function arrayToDOM(array $array, DOMElement $rootElement, ?string $charset = null): DOMElement
{
foreach ($array as $key => $value) {
if (is_numeric($key)) {
$key = $rootElement->nodeName;
- 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 addForeignKeys
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function addForeignKeys(Table $table): void
{
$database = $table->getDatabase();
/** @var \PDOStatement $stmt */
- 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 addMutatorCloseBody
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function addMutatorCloseBody(string &$script, Column $column): void
{
$table = $this->getTable();
if ($column->isForeignKey()) {
- 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 addToArray
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function addToArray(string &$script): void
{
$fks = $this->getTable()->getForeignKeys();
$referrers = $this->getTable()->getReferrers();
$hasFks = count($fks) > 0 || count($referrers) > 0;
- 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 addColumnMutatorMethods
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function addColumnMutatorMethods(string &$script): void
{
foreach ($this->getTable()->getColumns() as $col) {
if ($col->getType() === PropelTypes::OBJECT) {
$this->addObjectMutator($script, $col);
- 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 compareForeignKeys
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function compareForeignKeys(bool $caseInsensitive = false): int
{
$fkDifferences = 0;
$fromTableFks = $this->getFromTable()->getForeignKeys();
$toTableFks = $this->getToTable()->getForeignKeys();
- 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 __toString
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function __toString(): string
{
$tables = [];
foreach ($this->getTables() as $table) {
$columns = [];
- 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 addMakeSlugUnique
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addMakeSlugUnique(string &$script): void
{
$script .= "
/**
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function addRetrieveTree(string &$script): void
{
$queryClassName = $this->queryClassName;
$objectClassName = $this->objectClassName;
$useScope = $this->behavior->useScope();
- 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 129.
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