src/Http/Controllers/Character/IntelController.php

Summary

Maintainability
F
4 days
Test Coverage

File IntelController.php has 511 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * This file is part of SeAT
 *
Severity: Major
Found in src/Http/Controllers/Character/IntelController.php - About 1 day to fix

    Method getTransactionContent has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getTransactionContent(CharacterInfo $character, int $client_id)
        {
    
            $character_ids = collect($character->character_id);
    
    
    Severity: Major
    Found in src/Http/Controllers/Character/IntelController.php - About 2 hrs to fix

      Method getJournalContent has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getJournalContent(CharacterInfo $character, int $first_party_id, int $second_party_id, string $ref_type)
          {
      
              $character_ids = collect($character->character_id);
      
      
      Severity: Minor
      Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

        Method getTopWalletJournalData has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getTopWalletJournalData(CharacterInfo $character)
            {
        
                if (! request()->has('characters'))
                    return abort(500);
        Severity: Minor
        Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

          Method getTopTransactionsData has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getTopTransactionsData(CharacterInfo $character)
              {
          
                  if (! request()->has('characters'))
                      return abort(500);
          Severity: Minor
          Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

            Method getCharacterJournalStandingsWithProfile has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getCharacterJournalStandingsWithProfile(int $character_id, int $profile_id)
                {
            
                    return CharacterAffiliation::with('character', 'corporation', 'alliance', 'faction')
                        ->select(
            Severity: Minor
            Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

              Method getTopMailContent has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getTopMailContent(CharacterInfo $character, int $from)
                  {
              
                      $character_ids = collect($character->character_id);
              
              
              Severity: Minor
              Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

                Method characterTopWalletJournalInteractions has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function characterTopWalletJournalInteractions(Collection $character_ids): Builder
                    {
                
                        return CharacterWalletJournal::select('first_party_id', 'second_party_id', 'ref_type', 'category', 'entity_id as party_id', 'name as party_name', DB::raw('count(*) as total'),
                            DB::raw("
                Severity: Minor
                Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

                  Method characterWalletTransactionInteraction has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function characterWalletTransactionInteraction(Collection $character_ids, int $client_id): Builder
                      {
                  
                          return CharacterWalletTransaction::with('party', 'type', 'location')
                              ->select(DB::raw('
                  Severity: Minor
                  Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

                    Method getTopMailFromData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getTopMailFromData(CharacterInfo $character)
                        {
                    
                            if (! request()->has('characters'))
                                return abort(500);
                    Severity: Minor
                    Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

                      Method characterTopMailInteractions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function characterTopMailInteractions(Collection $character_ids): Builder
                          {
                              return MailHeader::select('from', 'entity_id as character_id', 'name as character_name', DB::raw('COUNT(*) as total'),
                                  DB::raw("
                                      CASE 
                      Severity: Minor
                      Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

                        Method characterTopWalletTransactionInteractions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function characterTopWalletTransactionInteractions(Collection $character_ids): Builder
                            {
                        
                                return CharacterWalletTransaction::select('client_id', 'category', 'entity_id as party_id', 'name as party_name', DB::raw('count(*) as total'),
                                    DB::raw("
                        Severity: Minor
                        Found in src/Http/Controllers/Character/IntelController.php - About 1 hr to fix

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

                          class IntelController extends Controller
                          {
                              /**
                               * @var int
                               */

                          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 unused parameters such as '$key'.
                          Open

                                  $character_ids = $character_ids->filter(function ($value, $key) use ($requested_characters) {

                          UnusedFormalParameter

                          Since: 0.2

                          Avoid passing parameters to methods or constructors and then not using those parameters.

                          Example

                          class Foo
                          {
                              private function bar($howdy)
                              {
                                  // $howdy is not used
                              }
                          }

                          Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                          Avoid unused parameters such as '$key'.
                          Open

                                  $character_ids = $character_ids->filter(function ($value, $key) use ($requested_characters) {

                          UnusedFormalParameter

                          Since: 0.2

                          Avoid passing parameters to methods or constructors and then not using those parameters.

                          Example

                          class Foo
                          {
                              private function bar($howdy)
                              {
                                  // $howdy is not used
                              }
                          }

                          Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

                                  return DataTables::of($top)
                                      ->editColumn('ref_type', function ($row) {
                          
                                          return ucwords(str_replace('_', ' ', $row->ref_type));
                                      })
                          Severity: Major
                          Found in src/Http/Controllers/Character/IntelController.php and 1 other location - About 2 hrs to fix
                          src/Http/Controllers/Character/IntelController.php on lines 157..171

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

                          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

                                  return DataTables::of($top)
                                      ->editColumn('entity_name', function ($row) {
                                          if($row->category == 'character') {
                                              $character = (object) ['character_id' => $row->party_id, 'name' => $row->party_name];
                          
                          
                          Severity: Major
                          Found in src/Http/Controllers/Character/IntelController.php and 1 other location - About 2 hrs to fix
                          src/Http/Controllers/Character/IntelController.php on lines 89..108

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

                          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

                                  return DataTables::of($mail)
                                      ->editColumn('sender.name', function ($row) {
                                          switch ($row->sender->category) {
                                              case 'character':
                                                  return view('web::partials.character', ['character' => $row->sender]);
                          Severity: Major
                          Found in src/Http/Controllers/Character/IntelController.php and 1 other location - About 2 hrs to fix
                          src/Http/Controllers/Character/IntelController.php on lines 397..437

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

                          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

                                  return DataTables::of($transactions)
                                      ->editColumn('date', function ($row) {
                                          return view('web::partials.date', ['datetime' => $row->date]);
                                      })
                                      ->editColumn('is_buy', function ($row) {
                          Severity: Major
                          Found in src/Http/Controllers/Character/IntelController.php and 1 other location - About 2 hrs to fix
                          src/Http/Controllers/Character/IntelController.php on lines 471..485

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

                          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

                                  return DataTables::of($journal)
                                      ->editColumn('ref_type', function ($row) {
                          
                                          return view('web::common.wallets.journaltranstype', compact('row'));
                                      })
                          Severity: Major
                          Found in src/Http/Controllers/Character/IntelController.php and 1 other location - About 2 hrs to fix
                          src/Http/Controllers/Character/IntelController.php on lines 320..358

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

                          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

                                  return CharacterWalletJournal::select('first_party_id', 'second_party_id', 'ref_type', 'category', 'entity_id as party_id', 'name as party_name', DB::raw('count(*) as total'),
                                      DB::raw("
                                          CASE 
                                              when universe_names.category = 'character' then 
                                                  (SELECT corporation_id FROM character_affiliations WHERE character_id = universe_names.entity_id) 
                          Severity: Major
                          Found in src/Http/Controllers/Character/IntelController.php and 1 other location - About 1 hr to fix
                          src/Http/Controllers/Character/IntelController.php on lines 534..538

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

                          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

                                          CharacterWalletJournal::select('first_party_id', 'second_party_id', 'ref_type', 'category', 'entity_id as party_id', 'name as party_name', DB::raw('count(*) as total'), DB::raw("CASE when universe_names.category = 'character' then (SELECT corporation_id FROM character_affiliations WHERE character_id = universe_names.entity_id) when universe_names.category = 'corporation' then (SELECT corporation_id FROM character_affiliations WHERE corporation_id = universe_names.entity_id LIMIT 1) end AS corporation_id, CASE when universe_names.category = 'character' then (SELECT alliance_id FROM character_affiliations WHERE character_id = universe_names.entity_id) when universe_names.category = 'corporation' then (SELECT alliance_id FROM character_affiliations WHERE corporation_id = universe_names.entity_id LIMIT 1) end AS alliance_id, CASE when universe_names.category = 'character' then (SELECT faction_id FROM character_affiliations WHERE character_id = universe_names.entity_id) when universe_names.category = 'corporation' then (SELECT faction_id FROM character_affiliations WHERE corporation_id = universe_names.entity_id LIMIT 1) end AS faction_id"))
                                              ->leftJoin('universe_names', 'universe_names.entity_id', '=', 'character_wallet_journals.second_party_id')
                                              ->whereIn('character_wallet_journals.character_id', $character_ids->toArray())
                                              ->whereNotIn('character_wallet_journals.second_party_id', $character_ids->toArray())
                                              ->groupBy('first_party_id', 'second_party_id', 'ref_type', 'category', 'party_id', 'party_name')
                          Severity: Major
                          Found in src/Http/Controllers/Character/IntelController.php and 1 other location - About 1 hr to fix
                          src/Http/Controllers/Character/IntelController.php on lines 507..532

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

                          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 excessively long variable names like $related_characters_ids. Keep variable name length under 20.
                          Open

                                      $related_characters_ids = User::find($character->refresh_token->user_id)

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

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

                          Avoid excessively long variable names like $related_characters_ids. Keep variable name length under 20.
                          Open

                                      $related_characters_ids = User::find($character->refresh_token->user_id)

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

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

                          Avoid excessively long variable names like $related_characters_ids. Keep variable name length under 20.
                          Open

                                      $related_characters_ids = User::find($character->refresh_token->user_id)

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

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

                          Avoid excessively long variable names like $related_characters_ids. Keep variable name length under 20.
                          Open

                                      $related_characters_ids = User::find($character->refresh_token->user_id)

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

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

                          Avoid excessively long variable names like $related_characters_ids. Keep variable name length under 20.
                          Open

                                      $related_characters_ids = User::find($character->refresh_token->user_id)

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

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

                          Avoid excessively long variable names like $related_characters_ids. Keep variable name length under 20.
                          Open

                                      $related_characters_ids = User::find($character->refresh_token->user_id)

                          LongVariable

                          Since: 0.2

                          Detects when a field, formal or local variable is declared with a long name.

                          Example

                          class Something {
                              protected $reallyLongIntName = -3; // VIOLATION - Field
                              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                  $otherReallyLongName = -5; // VIOLATION - Local
                                  for ($interestingIntIndex = 0; // VIOLATION - For
                                       $interestingIntIndex < 10;
                                       $interestingIntIndex++ ) {
                                  }
                              }
                          }

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

                          There are no issues that match your filters.

                          Category
                          Status