Showing 313 of 313 total issues
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class AddLengthAndPageCountFieldsToTopicPdfsTable extends Migration
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class AddLengthColumnToTopicVideosTable extends Migration
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class CreateTopicImagesTable extends Migration
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class CreateTopicOembedsTable extends Migration
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class AddLengthFieldToTopicRichtextsTable extends Migration
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class CreateTopicPdfsTable extends Migration
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class CreateTopicAudiosTable extends Migration
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class CreateTopicVideosTable extends Migration
- Exclude checks
Function fixAssetPaths
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function fixAssetPaths(): array
{
$topic = $this->topic;
$course = $topic->lesson->course;
$destinationValue = sprintf(
- 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
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 20 and the first side effect is on line 8. Open
<?php
- Exclude checks
The class CoursesWithTopicSeeder has a coupling between objects value of 22. Consider to reduce the number of dependencies under 13. Open
class CoursesWithTopicSeeder extends Seeder
{
use WithFaker;
private function getRandomRichContent(bool $withH5P = false): Factory
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 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) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
The class EscolaLmsTopicTypesServiceProvider has a coupling between objects value of 45. Consider to reduce the number of dependencies under 13. Open
class EscolaLmsTopicTypesServiceProvider extends ServiceProvider
{
public $singletons = [
TopicTypeServiceContract::class => TopicTypeService::class,
];
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 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) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (strpos($this->poster, $destinationPoster) === false && Storage::exists($this->poster)) {
if (!Storage::exists($destinationPoster)) {
Storage::move($this->poster, $destinationPoster);
}
$results[] = [$this->poster, $destinationPoster];
- 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 93.
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
if (strpos($this->value, $destinationValue) === false && Storage::exists($this->value)) {
if (!Storage::exists($destinationValue)) {
Storage::move($this->value, $destinationValue);
}
$results[] = [$this->value, $destinationValue];
- 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 93.
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
Empty lines are not allowed in multi-line function calls Open
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$model::all()->each(function($m) {
- Exclude checks
Possible parse error: class missing opening or closing brace Open
class Markdown
- Exclude checks
Possible parse error: class missing opening or closing brace Open
class Markdown
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
The method getRandomRichContent has a boolean flag argument $withH5P, which is a certain sign of a Single Responsibility Principle violation. Open
private function getRandomRichContent(bool $withH5P = false): Factory
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 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) {
}
}