EscolaLMS/topic-types

View on GitHub

Showing 259 of 259 total issues

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

<?php

namespace EscolaLms\TopicTypes\Http\Resources\TopicType\Export;

use EscolaLms\TopicTypes\Http\Resources\TopicType\Contacts\TopicTypeResourceContract;
Severity: Major
Found in src/Http/Resources/TopicType/Export/ScormScoResource.php and 1 other location - About 2 hrs to fix
src/Http/Resources/TopicType/Export/Cmi5AuResource.php on lines 1..27

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

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

<?php

namespace EscolaLms\TopicTypes\Http\Resources\TopicType\Export;

use EscolaLms\Cmi5\Models\Cmi5Au;
Severity: Major
Found in src/Http/Resources/TopicType/Export/Cmi5AuResource.php and 1 other location - About 2 hrs to fix
src/Http/Resources/TopicType/Export/ScormScoResource.php on lines 1..27

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

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

Method boot has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function boot()
    {
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
        $this->mergeConfigFrom(__DIR__ . '/../config/topic-h5p.php', 'topic-h5p');
        if ($this->app->runningInConsole()) {
Severity: Major
Found in src/EscolaLmsTopicTypesServiceProvider.php - About 2 hrs to fix

    Method run has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run()
        {
            $this->faker = $this->makeFaker();
            $this->faker->addProvider(new FakerProvider($this->faker));
            $randomTags = [
    Severity: Major
    Found in database/seeders/CoursesWithTopicSeeder.php - About 2 hrs to fix

      Avoid excessively long class names like AddLengthAndPageCountFieldsToTopicPdfsTable. Keep class name length under 40.
      Open

      class AddLengthAndPageCountFieldsToTopicPdfsTable extends Migration
      {
          public function up(): void
          {
              Schema::table('topic_pdfs', function (Blueprint $table) {

      LongClassName

      Since: 2.9

      Detects when classes or interfaces are declared with excessively long names.

      Example

      class ATooLongClassNameThatHintsAtADesignProblem {
      
      }
      
      interface ATooLongInterfaceNameThatHintsAtADesignProblem {
      
      }

      Source https://phpmd.org/rules/naming.html#longclassname

      Avoid using short method names like CreateTopicCmi5AusTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_cmi5_aus', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->string('value', 255);

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicVideosTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_videos', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicScormScosTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_scorm_scos', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like AddLengthAndPageCountFieldsToTopicPdfsTable::up(). The configured minimum method name length is 3.
      Open

          public function up(): void
          {
              Schema::table('topic_pdfs', function (Blueprint $table) {
                  $table->bigInteger('length')->nullable();
                  $table->integer('page_count')->nullable();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicImagesTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_images', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like AddLengthColumnToTopicVideosTable::up(). The configured minimum method name length is 3.
      Open

          public function up(): void
          {
              Schema::table('topic_videos', function (Blueprint $table) {
                  $table->bigInteger('length')->nullable();
              });

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicAudiosTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_audios', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicPdfsTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_pdfs', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicOembedsTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_oembeds', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like AddLengthFieldToTopicRichtextsTable::up(). The configured minimum method name length is 3.
      Open

          public function up(): void
          {
              Schema::table('topic_richtexts', function (Blueprint $table) {
                  $table->bigInteger('length')->nullable();
              });

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicH5PsTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_h5ps', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Avoid using short method names like CreateTopicRichtextsTable::up(). The configured minimum method name length is 3.
      Open

          public function up()
          {
              Schema::create('topic_richtexts', function (Blueprint $table) {
                  $table->bigIncrements('id');
                  $table->timestamps();

      ShortMethodName

      Since: 0.2

      Detects when very short method names are used.

      Example

      class ShortMethod {
          public function a( $index ) { // Violation
          }
      }

      Source https://phpmd.org/rules/naming.html#shortmethodname

      Method fixAssetPaths has 33 lines of code (exceeds 25 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 1 hr to fix

        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 CreateTopicRichtextsTable extends Migration
        Severity
        Category
        Status
        Source
        Language