herpaderpaldent/seat-notifications

View on GitHub

Showing 135 of 135 total issues

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

    public function postConfiguration(ValidateOAuth $request)
    {
        $state = time();

        // store data into the session until OAuth confirmation
Severity: Major
Found in src/Http/Controllers/Discord/DiscordServerController.php and 1 other location - About 1 hr to fix
src/Http/Controllers/Slack/SlackServerOAuthController.php on lines 43..56

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

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 execute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute(array $data)
    {
        try {

            $subscription = NotificationRecipient::where('driver_id', $data['driver_id'])
Severity: Minor
Found in src/Http/Actions/UnsubscribeAction.php - About 1 hr to fix

    Method handle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handle()
        {
    
            // Check if victim and attacker details are present yet.
            if(empty($this->killmail_detail->victims) || empty($this->killmail_detail->attackers)){
    Severity: Minor
    Found in src/Jobs/KillmaillDispatcher.php - About 1 hr to fix

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

              Schema::create('herpaderp_seat_notification_notification_recipients', function (Blueprint $table) {
                  $table->string('channel_id');
                  $table->string('name');
                  $table->json('affiliation')->nullable()->default(null);
                  $table->timestamps();
      src/database/migrations/2019_02_26_195245_version_2_migrations.php on lines 85..95

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

      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

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

              Schema::create('herpaderp_seat_notification_notification_recipients', function (Blueprint $table) {
                  $table->string('channel_id');
                  $table->string('name');
                  $table->json('affiliation')->nullable()->default(null);
                  $table->timestamps();
      src/database/migrations/2019_01_22_194232_create_seat_notifications_table.php on lines 54..64

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

      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

      Avoid variables with short names like $i. Configured minimum length is 3.
      Open

              $i = count($expected_array_keys);

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $id. Configured minimum length is 3.
      Open

          public function resolveID($id, $is_alliance = false)

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $i. Configured minimum length is 3.
      Open

              $i = count($expected_array_keys);

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $id. Configured minimum length is 3.
      Open

          private function getAllianceTicker($id)

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $id. Configured minimum length is 3.
      Open

          public function zKillBoardToLink(string $type, int $id)

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      Avoid variables with short names like $id. Configured minimum length is 3.
      Open

          public function hasAffiliation(string $type, int $id) : bool

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

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

      The class SeatNotificationsController has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
      Open

      class SeatNotificationsController extends Controller
      {
          use Character;
          use Corporation;
      
      

      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

      Avoid too many return statements within this method.
      Open

              return redirect()->route('seatnotifications.configuration')
                  ->with('success', 'The bot credentials has been set.');
      Severity: Major
      Found in src/Http/Controllers/Discord/DiscordServerController.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return $this->subscribe_action->execute($data);
        Severity: Major
        Found in src/Http/Controllers/Slack/SlackUserOAuthController.php - About 30 mins to fix

          The method field has a boolean flag argument $inline, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public function field($name, $value, $inline = false)
          Severity: Minor
          Found in src/Channels/Discord/DiscordEmbed.php by phpmd

          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

          The method inline has a boolean flag argument $inline, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public function inline($inline = true)

          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

          Avoid too many return statements within this method.
          Open

                      return redirect()->route('seatnotifications.configuration')
                          ->with('error', 'An error occurred while trying to create websocket connection with Discord. ' .
                              $e->getMessage());
          Severity: Major
          Found in src/Http/Controllers/Discord/DiscordServerController.php - About 30 mins to fix

            The method tts has a boolean flag argument $enabled, which is a certain sign of a Single Responsibility Principle violation.
            Open

                public function tts($enabled = true)

            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

            Avoid too many return statements within this method.
            Open

                    return redirect()->route('seatnotifications.configuration')
                        ->with('success', 'The bot credentials has been set.');
            Severity: Major
            Found in src/Http/Controllers/Slack/SlackServerOAuthController.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return redirect()->route('seatnotifications.configuration')
                                  ->with('error', 'An error occurred while trying to create websocket connection with Discord. ' .
                                      $identified);
              Severity: Major
              Found in src/Http/Controllers/Discord/DiscordServerController.php - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language