pixelfed/pixelfed

View on GitHub
app/Http/Controllers/SearchController.php

Summary

Maintainability
D
1 day
Test Coverage

File SearchController.php has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers;

use App\Hashtag;
Severity: Minor
Found in app/Http/Controllers/SearchController.php - About 3 hrs to fix

    Method getProfiles has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getProfiles()
        {
            $tag = $this->term;
            $remoteKey = $this->cacheKey.'profiles:remote:'.$this->hash;
            $key = $this->cacheKey.'profiles:'.$this->hash;
    Severity: Major
    Found in app/Http/Controllers/SearchController.php - About 2 hrs to fix

      Method getPosts has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getPosts()
          {
              $tag = $this->term;
              $hash = hash('sha256', $tag);
              if (Helpers::validateUrl($tag) != false &&
      Severity: Minor
      Found in app/Http/Controllers/SearchController.php - About 1 hr to fix

        Method remotePostLookup has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function remotePostLookup()
            {
                $tag = $this->term;
                $hash = hash('sha256', $tag);
                $local = Helpers::validateLocalUrl($tag);
        Severity: Minor
        Found in app/Http/Controllers/SearchController.php - About 1 hr to fix

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

              public function searchAPI(Request $request)
              {
                  $this->validate($request, [
                      'q' => 'required|string|min:3|max:120',
                      'src' => 'required|string|in:metro',
          Severity: Minor
          Found in app/Http/Controllers/SearchController.php - About 1 hr to fix

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

                protected function getPlaces()
                {
                    $tag = $this->term;
                    // $key = $this->cacheKey . 'places:' . $this->hash;
                    // $ttl = now()->addHours(12);
            Severity: Minor
            Found in app/Http/Controllers/SearchController.php - About 1 hr to fix

              Function getProfiles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getProfiles()
                  {
                      $tag = $this->term;
                      $remoteKey = $this->cacheKey.'profiles:remote:'.$this->hash;
                      $key = $this->cacheKey.'profiles:'.$this->hash;
              Severity: Minor
              Found in app/Http/Controllers/SearchController.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

              Function remotePostLookup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function remotePostLookup()
                  {
                      $tag = $this->term;
                      $hash = hash('sha256', $tag);
                      $local = Helpers::validateLocalUrl($tag);
              Severity: Minor
              Found in app/Http/Controllers/SearchController.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

              Function getPosts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getPosts()
                  {
                      $tag = $this->term;
                      $hash = hash('sha256', $tag);
                      if (Helpers::validateUrl($tag) != false &&
              Severity: Minor
              Found in app/Http/Controllers/SearchController.php - About 45 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

              Function searchAPI has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function searchAPI(Request $request)
                  {
                      $this->validate($request, [
                          'q' => 'required|string|min:3|max:120',
                          'src' => 'required|string|in:metro',
              Severity: Minor
              Found in app/Http/Controllers/SearchController.php - About 45 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

              There are no issues that match your filters.

              Category
              Status