Showing 12 of 12 total issues
Method processManyToManyChange
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function processManyToManyChange($relation_method_name, $new_value, $override_relationship_method = null)
{
// The join between the model and the other model
$relation = $this->$relation_method_name();
Function bootLogChangeTrait
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function bootLogChangeTrait()
{
// Saved model event
static::saved(function ($model) {
- 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 getModelChangeDiff
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function getModelChangeDiff($column_name, &$log_change, $old_text, $new_text)
{
if (is_array($old_text) && is_array($new_text)) {
$difference = (new MapDiffer())->doDiff($old_text, $new_text);
- 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 bootLogChangeTrait
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function bootLogChangeTrait()
{
// Saved model event
static::saved(function ($model) {
Method getModelChangeDiff
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function getModelChangeDiff($column_name, &$log_change, $old_text, $new_text)
{
if (is_array($old_text) && is_array($new_text)) {
$difference = (new MapDiffer())->doDiff($old_text, $new_text);
Function bootChangeByUserTrait
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function bootChangeByUserTrait()
{
static::creating(function ($model) {
if (!App::runningInConsole() && Auth::check()) {
if ($model->getCreatedByColumn()) {
- 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 addModelChange
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
$model_id,
$table_name,
$column_name,
$old_text,
$new_text,
Function handle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function handle()
{
// Read the app folder & save
$models = Storage::disk('models')->allFiles();
- 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 processManyToManyChange
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function processManyToManyChange($relation_method_name, $new_value, $override_relationship_method = null)
{
// The join between the model and the other model
$relation = $this->$relation_method_name();
- 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
Avoid assigning values to variables in if clauses and the like (line '131', column '39'). Open
public function processManyToManyChange($relation_method_name, $new_value, $override_relationship_method = null)
{
// The join between the model and the other model
$relation = $this->$relation_method_name();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '141', column '39'). Open
public function processManyToManyChange($relation_method_name, $new_value, $override_relationship_method = null)
{
// The join between the model and the other model
$relation = $this->$relation_method_name();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method processManyToManyChange() has 103 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function processManyToManyChange($relation_method_name, $new_value, $override_relationship_method = null)
{
// The join between the model and the other model
$relation = $this->$relation_method_name();
- Exclude checks