EscolaLMS/topic-types

View on GitHub

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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class AddLengthColumnToTopicVideosTable extends Migration

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class CreateTopicImagesTable extends Migration

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class CreateTopicOembedsTable extends Migration

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class AddLengthFieldToTopicRichtextsTable extends Migration

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class CreateTopicPdfsTable extends Migration

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class CreateTopicAudiosTable extends Migration

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class CreateTopicVideosTable extends Migration

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(
Severity: Minor
Found in src/Models/TopicContent/Video.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"

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
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

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

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,
    ];

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];
Severity: Minor
Found in src/Models/TopicContent/Video.php and 1 other location - About 40 mins to fix
src/Models/TopicContent/Video.php on lines 127..133

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

Further Reading

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];
Severity: Minor
Found in src/Models/TopicContent/Video.php and 1 other location - About 40 mins to fix
src/Models/TopicContent/Video.php on lines 134..140

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

Further Reading

Empty lines are not allowed in multi-line function calls
Open


Expected 1 space after FUNCTION keyword; 0 found
Open

        $model::all()->each(function($m) {

Possible parse error: class missing opening or closing brace
Open

class Markdown
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Possible parse error: class missing opening or closing brace
Open

class Markdown
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

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

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) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Severity
Category
Status
Source
Language