# yiisoft/yii2

framework/db/BaseActiveRecord.php

### Summary

F
4 days

#### Function unlink has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open

    public function unlink($name,$model, $delete = false) {$relation = $this->getRelation($name);

if ($relation->via !== null) { Found in framework/db/BaseActiveRecord.php - About 1 day 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 link has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open  public function link($name, $model,$extraColumns = [])
{
$relation =$this->getRelation($name); if ($relation->via !== null) {
Found in framework/db/BaseActiveRecord.php - About 6 hrs 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"

#### Function unlinkAll has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open

    public function unlinkAll($name,$delete = false)
{
$relation =$this->getRelation($name); if ($relation->via !== null) {
Found in framework/db/BaseActiveRecord.php - About 5 hrs 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"

#### The class BaseActiveRecord has 43 public methods. Consider refactoring BaseActiveRecord to keep number of public methods under 10. Open

abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
{
/**
* @event Event an event that is triggered when the record is initialized via [[init()]].
*/
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects. By default it ignores methods starting with 'get' or 'set'.

Source: http://phpmd.org/rules/codesize.txt

#### The class BaseActiveRecord has 49 non-getter- and setter-methods. Consider refactoring BaseActiveRecord to keep number of methods under 25. Open

abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
{
/**
* @event Event an event that is triggered when the record is initialized via [[init()]].
*/
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.1

A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects. By default it ignores methods starting with 'get' or 'set'. The default was changed from 10 to 25 in PHPMD 2.3.

Source: http://phpmd.org/rules/codesize.txt

#### The class BaseActiveRecord has an overall complexity of 244 which is very high. The configured complexity threshold is 50. Open

abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
{
/**
* @event Event an event that is triggered when the record is initialized via [[init()]].
*/
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.2.5

The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.

Example:

class Foo {
public function bar() {
if ($a ==$b)  {
if ($a1 ==$b1) {
fiddle();
} elseif ($a2 ==$b2) {
fiddle();
} else {
}
}
}
public function baz() {
if ($a ==$b) {
if ($a1 ==$b1) {
fiddle();
} elseif ($a2 ==$b2) {
fiddle();
} else {
}
}
}
// Several other complex methods
}

    public function getAttributeHint($attribute) {$hints = $this->attributeHints(); if (isset($hints[$attribute])) { return$hints[$attribute]; Found in framework/db/BaseActiveRecord.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 getAttributeLabel has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open  public function getAttributeLabel($attribute)
{
$labels =$this->attributeLabels();
if (isset($labels[$attribute])) {
return $labels[$attribute];
Found in framework/db/BaseActiveRecord.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"

#### Function getDirtyAttributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open

    public function getDirtyAttributes($names = null) { if ($names === null) {
$names =$this->attributes();
}
Found in framework/db/BaseActiveRecord.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"

#### Function getRelation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open

    public function getRelation($name,$throwException = true)
{
$getter = 'get' .$name;
try {
// the relation could be defined in a behavior
Found in framework/db/BaseActiveRecord.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"

#### The class BaseActiveRecord has 58 public methods and attributes. Consider reducing the number of public items to less than 45. Open

abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
{
/**
* @event Event an event that is triggered when the record is initialized via [[init()]].
*/
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.1

A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

Example:

public class Foo {
public $value; public$something;
public $var; // [... more more public attributes ...] public function doWork() {} public function doMoreWork() {} public function doWorkAgain() {} // [... more more public methods ...] } #### Function setRelationDependencies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open  private function setRelationDependencies($name, $relation,$viaRelationName = null)
{
if (empty($relation->via) &&$relation->link) {
foreach ($relation->link as$attribute) {
$this->_relationsDependencies[$attribute][$name] =$name;
Found in framework/db/BaseActiveRecord.php - About 55 mins 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"

#### Function updateAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open

    public function updateAttributes($attributes) {$attrs = [];
foreach ($attributes as$name => $value) { if (is_int($name)) {
Found in framework/db/BaseActiveRecord.php - About 35 mins 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"

#### Function updateInternal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open

    protected function updateInternal($attributes = null) { if (!$this->beforeSave(false)) {
return false;
}
Found in framework/db/BaseActiveRecord.php - About 35 mins 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"

#### Function updateCounters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open

    public function updateCounters($counters) { if (static::updateAllCounters($counters, $this->getOldPrimaryKey(true)) > 0) { foreach ($counters as $name =>$value) {
if (!isset($this->_attributes[$name])) {
Found in framework/db/BaseActiveRecord.php - About 35 mins 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"

        return $value; Found in framework/db/BaseActiveRecord.php - About 30 mins to fix #### Function setAttribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open  public function setAttribute($name, $value) { if ($this->hasAttribute($name)) { if ( !empty($this->_relationsDependencies[$name]) Found in framework/db/BaseActiveRecord.php - About 25 mins 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 __get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open  public function __get($name)
{
if (isset($this->_attributes[$name]) || array_key_exists($name,$this->_attributes)) {
return $this->_attributes[$name];
}
Found in framework/db/BaseActiveRecord.php - About 25 mins 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"

#### Function delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

    public function delete()
{
$result = false; if ($this->beforeDelete()) {
// we do not check the return value of deleteAll() because it's possible
Found in framework/db/BaseActiveRecord.php - About 25 mins 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"

#### Function __set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

    public function __set($name,$value)
{
if ($this->hasAttribute($name)) {
if (
!empty($this->_relationsDependencies[$name])
Found in framework/db/BaseActiveRecord.php - About 25 mins 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"

#### Function bindModels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

    private function bindModels($link,$foreignModel, $primaryModel) { foreach ($link as $fk =>$pk) {
$value =$primaryModel->$pk; if ($value === null) {
Found in framework/db/BaseActiveRecord.php - About 25 mins 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"

#### The class BaseActiveRecord has 1712 lines of code. Current threshold is 1000. Avoid really long classes. Open

abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
{
/**
* @event Event an event that is triggered when the record is initialized via [[init()]].
*/
Found in framework/db/BaseActiveRecord.php by phpmd

#### The method unlink() has an NPath complexity of 380. The configured NPath complexity threshold is 200. Open

    public function unlink($name,$model, $delete = false) {$relation = $this->getRelation($name);

if ($relation->via !== null) { Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 0.1 The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity. Example: class Foo { function bar() { // lots of complicated code } } #### The method link() has an NPath complexity of 760. The configured NPath complexity threshold is 200. Open  public function link($name, $model,$extraColumns = [])
{
$relation =$this->getRelation($name); if ($relation->via !== null) {
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example:

class Foo {
function bar() {
// lots of complicated code
}
}

#### The method unlinkAll() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open

    public function unlinkAll($name,$delete = false)
{
$relation =$this->getRelation($name); if ($relation->via !== null) {
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example:

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a ==$b) {
3           if ($a1 ==$b1) {
fiddle();
4           } elseif ($a2 ==$b2) {
fiddle();
} else {
fiddle();
}
5       } elseif ($c ==$d) {
6           while ($c ==$d) {
fiddle();
}
7        } elseif ($e ==$f) {
8           for ($n = 0;$n < $h;$n++) {
fiddle();
}
} else {
switch ($z) { 9 case 1: fiddle(); break; 10 case 2: fiddle(); break; 11 case 3: fiddle(); break; default: fiddle(); break; } } } } #### The method link() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10. Open  public function link($name, $model,$extraColumns = [])
{
$relation =$this->getRelation($name); if ($relation->via !== null) {
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example:

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a ==$b) {
3           if ($a1 ==$b1) {
fiddle();
4           } elseif ($a2 ==$b2) {
fiddle();
} else {
fiddle();
}
5       } elseif ($c ==$d) {
6           while ($c ==$d) {
fiddle();
}
7        } elseif ($e ==$f) {
8           for ($n = 0;$n < $h;$n++) {
fiddle();
}
} else {
switch ($z) { 9 case 1: fiddle(); break; 10 case 2: fiddle(); break; 11 case 3: fiddle(); break; default: fiddle(); break; } } } } #### The method unlink() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10. Open  public function unlink($name, $model,$delete = false)
{
$relation =$this->getRelation($name); if ($relation->via !== null) {
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example:

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a ==$b) {
3           if ($a1 ==$b1) {
fiddle();
4           } elseif ($a2 ==$b2) {
fiddle();
} else {
fiddle();
}
5       } elseif ($c ==$d) {
6           while ($c ==$d) {
fiddle();
}
7        } elseif ($e ==$f) {
8           for ($n = 0;$n < $h;$n++) {
fiddle();
}
} else {
switch ($z) { 9 case 1: fiddle(); break; 10 case 2: fiddle(); break; 11 case 3: fiddle(); break; default: fiddle(); break; } } } } #### The class BaseActiveRecord has a coupling between objects value of 25. Consider to reduce the number of dependencies under 13. Open abstract class BaseActiveRecord extends Model implements ActiveRecordInterface { /** * @event Event an event that is triggered when the record is initialized via [[init()]]. */ Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.1.0 A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability Example: class Foo { /** * @var \foo\bar\X */ private$x = null;

/**
* @var \foo\bar\Y
*/
private $y = null; /** * @var \foo\bar\Z */ private$z = null;

public function setFoo(\Foo $foo) {} public function setBar(\Bar$bar) {}
public function setBaz(\Baz $baz) {} /** * @return \SplObjectStorage * @throws \OutOfRangeException * @throws \InvalidArgumentException * @throws \ErrorException */ public function process(\Iterator$it) {}

// ...
}

#### The method save has a boolean flag argument $runValidation, which is a certain sign of a Single Responsibility Principle violation. Open  public function save($runValidation = true, $attributeNames = null) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method update has a boolean flag argument $runValidation, which is a certain sign of a Single Responsibility Principle violation. Open  public function update($runValidation = true, $attributeNames = null) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method getRelation has a boolean flag argument $throwException, which is a certain sign of a Single Responsibility Principle violation. Open  public function getRelation($name, $throwException = true) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method canGetProperty has a boolean flag argument $checkVars, which is a certain sign of a Single Responsibility Principle violation. Open  public function canGetProperty($name, $checkVars = true,$checkBehaviors = true)
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example:

class Foo {
public function bar($flag = true) { } } #### The method canSetProperty has a boolean flag argument$checkVars, which is a certain sign of a Single Responsibility Principle violation. Open

    public function canSetProperty($name,$checkVars = true, $checkBehaviors = true) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method isAttributeChanged has a boolean flag argument $identical, which is a certain sign of a Single Responsibility Principle violation. Open  public function isAttributeChanged($name, $identical = true) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method unlinkAll has a boolean flag argument $delete, which is a certain sign of a Single Responsibility Principle violation. Open  public function unlinkAll($name, $delete = false) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method canSetProperty has a boolean flag argument $checkBehaviors, which is a certain sign of a Single Responsibility Principle violation. Open  public function canSetProperty($name, $checkVars = true,$checkBehaviors = true)
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example:

class Foo {
public function bar($flag = true) { } } #### The method getOldPrimaryKey has a boolean flag argument$asArray, which is a certain sign of a Single Responsibility Principle violation. Open

    public function getOldPrimaryKey($asArray = false) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method canGetProperty has a boolean flag argument $checkBehaviors, which is a certain sign of a Single Responsibility Principle violation. Open  public function canGetProperty($name, $checkVars = true,$checkBehaviors = true)
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example:

class Foo {
public function bar($flag = true) { } } #### The method getPrimaryKey has a boolean flag argument$asArray, which is a certain sign of a Single Responsibility Principle violation. Open

    public function getPrimaryKey($asArray = false) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 1.4.0 A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method. Example: class Foo { public function bar($flag = true) {
}
}

#### The method unlink has a boolean flag argument $delete, which is a certain sign of a Single Responsibility Principle violation. Open  public function unlink($name, $model,$delete = false)
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example:

class Foo {
public function bar($flag = true) { } } #### Avoid unused parameters such as '$condition'. Open

    public static function updateAll($attributes,$condition = '')
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example:

class Foo
{
private function bar($howdy) { //$howdy is not used
}
}

#### Avoid unused parameters such as '$row'. Open  public static function instantiate($row)
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example:

class Foo
{
private function bar($howdy) { //$howdy is not used
}
}

{
// $howdy is not used } } #### Avoid unused parameters such as '$condition'. Open

    public static function deleteAll($condition = null) Found in framework/db/BaseActiveRecord.php by phpmd Since: PHPMD 0.2 Avoid passing parameters to methods or constructors and then not using those parameters. Example: class Foo { private function bar($howdy)
{
// $howdy is not used } } #### Avoid unused parameters such as '$attributes'. Open

    public static function updateAll($attributes,$condition = '')
Found in framework/db/BaseActiveRecord.php by phpmd

Since: PHPMD 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example:

class Foo
{
private function bar($howdy) { //$howdy is not used
}
}

{
// $howdy is not used } } #### Similar blocks of code found in 2 locations. Consider refactoring. Open  if (is_array($relation->via)) {
/* @var $viaClass ActiveRecordInterface */ if ($delete) {
$viaClass::deleteAll($condition);
} else {
Found in framework/db/BaseActiveRecord.php and 1 other location - About 1 hr to fix
framework/db/BaseActiveRecord.php on lines 1413..1429

## 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

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

            if (is_array($relation->via)) { /* @var$viaClass ActiveRecordInterface */
if ($delete) {$viaClass::deleteAll(\$columns);
} else {
Found in framework/db/BaseActiveRecord.php and 1 other location - About 1 hr to fix
framework/db/BaseActiveRecord.php on lines 1513..1529

## 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.