src/Http/Controllers/Support/ResolveController.php

Summary

Maintainability
C
1 day
Test Coverage

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

    public function resolveIdsToNames(Request $request)
    {

        // Resolve the Esi client library from the IoC
        $eseye = app('esi-client')->get();
Severity: Minor
Found in src/Http/Controllers/Support/ResolveController.php - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                    return $collection->when($collection->isNotEmpty(), function ($ids) {
                        return $this->resolveFactionIDs($ids);
                    });
    Severity: Major
    Found in src/Http/Controllers/Support/ResolveController.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $collection->when($collection->isNotEmpty(), function ($ids) {
                          return $this->resolveInternalCharacterIDs($ids);
                      });
      Severity: Major
      Found in src/Http/Controllers/Support/ResolveController.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return $collection->when($collection->isNotEmpty(), function ($ids) {
                            return $this->resolveInternalUniverseIDs($ids);
                        });
        Severity: Major
        Found in src/Http/Controllers/Support/ResolveController.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return response()->json($this->response);
          Severity: Major
          Found in src/Http/Controllers/Support/ResolveController.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $collection->when($collection->isNotEmpty(), function ($ids) {
                                return $this->resolveInternalAllianceIDs($ids);
                            });
            Severity: Major
            Found in src/Http/Controllers/Support/ResolveController.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return $collection->when($collection->isNotEmpty(), function ($ids) {
                                  return $this->resolveInternalCorporationIDs($ids);
                              });
              Severity: Major
              Found in src/Http/Controllers/Support/ResolveController.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return;
                Severity: Major
                Found in src/Http/Controllers/Support/ResolveController.php - About 30 mins to fix

                  The method resolveIDsfromESI uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  //split the chunk in two
                                  $half = ceil($ids->count() / 2);
                                  //keep on processing the halfs independently,
                                  //ideally one of the halfs will process just perfect

                  ElseExpression

                  Since: 1.4.0

                  An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                  Example

                  class Foo
                  {
                      public function bar($flag)
                      {
                          if ($flag) {
                              // one branch
                          } else {
                              // another branch
                          }
                      }
                  }

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

                  Avoid assigning values to variables in if clauses and the like (line '92', column '21').
                  Open

                      public function resolveIdsToNames(Request $request)
                      {
                  
                          // Resolve the Esi client library from the IoC
                          $eseye = app('esi-client')->get();

                  IfStatementAssignment

                  Since: 2.7.0

                  Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                  Example

                  class Foo
                  {
                      public function bar($flag)
                      {
                          if ($foo = 'bar') { // possible typo
                              // ...
                          }
                          if ($baz = 0) { // always false
                              // ...
                          }
                      }
                  }

                  Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

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

                      private function resolveFactionIDs(Collection $ids)
                      {
                  
                          // universe resolver is not working on factions at this time
                          // retrieve them from SDE and remove them from collection
                  Severity: Minor
                  Found in src/Http/Controllers/Support/ResolveController.php and 1 other location - About 45 mins to fix
                  src/Http/Controllers/Support/ResolveController.php on lines 175..190

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

                  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

                      private function resolveInternalUniverseIDs(Collection $ids)
                      {
                          // resolve names that are already in SeAT
                          // no unnecessary api calls the request can be resolved internally.
                          $names = UniverseName::whereIn('entity_id', $ids->flatten()->toArray())
                  Severity: Minor
                  Found in src/Http/Controllers/Support/ResolveController.php and 1 other location - About 45 mins to fix
                  src/Http/Controllers/Support/ResolveController.php on lines 150..166

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

                  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 3 locations. Consider refactoring.
                  Open

                      private function resolveInternalCharacterIDs(Collection $ids)
                      {
                  
                          // resolve names that are already in SeAT
                          // no unnecessary api calls the request can be resolved internally.
                  Severity: Minor
                  Found in src/Http/Controllers/Support/ResolveController.php and 2 other locations - About 40 mins to fix
                  src/Http/Controllers/Support/ResolveController.php on lines 224..240
                  src/Http/Controllers/Support/ResolveController.php on lines 246..262

                  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 3 locations. Consider refactoring.
                  Open

                      private function resolveInternalCorporationIDs(Collection $ids)
                      {
                  
                          // resolve names that are already in SeAT
                          // no unnecessary api calls the request can be resolved internally.
                  Severity: Minor
                  Found in src/Http/Controllers/Support/ResolveController.php and 2 other locations - About 40 mins to fix
                  src/Http/Controllers/Support/ResolveController.php on lines 199..215
                  src/Http/Controllers/Support/ResolveController.php on lines 246..262

                  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 3 locations. Consider refactoring.
                  Open

                      private function resolveInternalAllianceIDs(Collection $ids)
                      {
                  
                          // resolve names that are already in SeAT
                          // no unnecessary api calls if the request can be resolved internally.
                  Severity: Minor
                  Found in src/Http/Controllers/Support/ResolveController.php and 2 other locations - About 40 mins to fix
                  src/Http/Controllers/Support/ResolveController.php on lines 199..215
                  src/Http/Controllers/Support/ResolveController.php on lines 224..240

                  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

                  There are no issues that match your filters.

                  Category
                  Status