pixelfed/pixelfed

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

Summary

Maintainability
F
1 wk
Test Coverage

File PublicApiController.php has 705 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
Severity: Major
Found in app/Http/Controllers/PublicApiController.php - About 1 day to fix

    Method homeTimelineApi has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function homeTimelineApi(Request $request)
        {
            if(!$request->user()) {
                return response('', 403);
            }
    Severity: Major
    Found in app/Http/Controllers/PublicApiController.php - About 5 hrs to fix

      Method publicTimelineApi has 132 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function publicTimelineApi(Request $request)
          {
              $this->validate($request,[
                'page'        => 'nullable|integer|max:40',
                'min_id'      => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
      Severity: Major
      Found in app/Http/Controllers/PublicApiController.php - About 5 hrs to fix

        Method networkTimelineApi has 111 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function networkTimelineApi(Request $request)
            {
                if(!$request->user()) {
                    return response('', 403);
                }
        Severity: Major
        Found in app/Http/Controllers/PublicApiController.php - About 4 hrs to fix

          Method accountStatuses has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function accountStatuses(Request $request, $id)
              {
                  $this->validate($request, [
                      'only_media' => 'nullable',
                      'pinned' => 'nullable',
          Severity: Major
          Found in app/Http/Controllers/PublicApiController.php - About 3 hrs to fix

            Function networkTimelineApi has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function networkTimelineApi(Request $request)
                {
                    if(!$request->user()) {
                        return response('', 403);
                    }
            Severity: Minor
            Found in app/Http/Controllers/PublicApiController.php - About 2 hrs 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 publicTimelineApi has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function publicTimelineApi(Request $request)
                {
                    $this->validate($request,[
                      'page'        => 'nullable|integer|max:40',
                      'min_id'      => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
            Severity: Minor
            Found in app/Http/Controllers/PublicApiController.php - About 2 hrs 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

            Method statusComments has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function statusComments(Request $request, $username, int $postId)
                {
                    $this->validate($request, [
                        'min_id'    => 'nullable|integer|min:1',
                        'max_id'    => 'nullable|integer|min:1|max:'.PHP_INT_MAX,
            Severity: Minor
            Found in app/Http/Controllers/PublicApiController.php - About 1 hr to fix

              Function scopeCheck has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function scopeCheck(Profile $profile, Status $status)
                  {
                      if($profile->is_private == true && Auth::check() == false) {
                          abort(404);
                      }
              Severity: Minor
              Found in app/Http/Controllers/PublicApiController.php - About 1 hr 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

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

                  protected function scopeCheck(Profile $profile, Status $status)
                  {
                      if($profile->is_private == true && Auth::check() == false) {
                          abort(404);
                      }
              Severity: Minor
              Found in app/Http/Controllers/PublicApiController.php - About 1 hr to fix

                Function accountStatuses has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function accountStatuses(Request $request, $id)
                    {
                        $this->validate($request, [
                            'only_media' => 'nullable',
                            'pinned' => 'nullable',
                Severity: Minor
                Found in app/Http/Controllers/PublicApiController.php - About 1 hr 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 statusComments has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function statusComments(Request $request, $username, int $postId)
                    {
                        $this->validate($request, [
                            'min_id'    => 'nullable|integer|min:1',
                            'max_id'    => 'nullable|integer|min:1|max:'.PHP_INT_MAX,
                Severity: Minor
                Found in app/Http/Controllers/PublicApiController.php - About 1 hr 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

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

                    public function statusState(Request $request, $username, int $postid)
                    {
                        $profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
                        $status = Status::whereProfileId($profile->id)->findOrFail($postid);
                        $this->scopeCheck($profile, $status);
                Severity: Minor
                Found in app/Http/Controllers/PublicApiController.php - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if($min || $max) {
                                  $dir = $min ? '>' : '<';
                                  $id = $min ?? $max;
                                  $timeline = Status::select(
                                              'id',
                  Severity: Major
                  Found in app/Http/Controllers/PublicApiController.php - About 40 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $s;
                    Severity: Major
                    Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return $status;
                      Severity: Major
                      Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $status;
                        Severity: Major
                        Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return response()->json($res);
                          Severity: Major
                          Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return response()->json($res);
                            Severity: Major
                            Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
                              Severity: Major
                              Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                                    return $status;
                                Severity: Major
                                Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
                                  Severity: Major
                                  Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                                   return $status;
                                    Severity: Major
                                    Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                                      return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
                                      Severity: Major
                                      Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                            return false;
                                        Severity: Major
                                        Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return response()->json($res);
                                          Severity: Major
                                          Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                                                   return false;
                                            Severity: Major
                                            Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                                              return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
                                              Severity: Major
                                              Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                            return $q->where('is_nsfw', false);
                                                Severity: Major
                                                Found in app/Http/Controllers/PublicApiController.php - About 30 mins to fix

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

                                                          if(config('instance.timeline.network.cached') == false) {
                                                              if($min || $max) {
                                                                  $dir = $min ? '>' : '<';
                                                                  $id = $min ?? $max;
                                                                  $timeline = Status::select(
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 day to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 247..364

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

                                                  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

                                                          if(config('exp.cached_public_timeline') == false) {
                                                              if($min || $max) {
                                                                  $dir = $min ? '>' : '<';
                                                                  $id = $min ?? $max;
                                                                  $timeline = Status::select(
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 day to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 541..634

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

                                                  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 Status::select(
                                                                          'id',
                                                                          'uri',
                                                                          'caption',
                                                                          'rendered',
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 3 hrs to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 415..458

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

                                                  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 Status::select(
                                                                          'id',
                                                                          'uri',
                                                                          'caption',
                                                                          'rendered',
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 3 hrs to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 465..507

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

                                                  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

                                                                  $timeline = Status::select(
                                                                              'id',
                                                                              'profile_id',
                                                                              'type',
                                                                              'scope',
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 2 hrs to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 285..324

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

                                                  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

                                                                  $timeline = Status::select(
                                                                              'id',
                                                                              'uri',
                                                                              'caption',
                                                                              'rendered',
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 2 hrs to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 251..278

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

                                                  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

                                                                  $timeline = Status::select(
                                                                              'id',
                                                                              'uri',
                                                                              'type',
                                                                              'scope',
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 hr to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 574..599

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

                                                  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

                                                                      $timeline = Status::select(
                                                                                  'id',
                                                                                  'uri',
                                                                                  'type',
                                                                                  'scope',
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 hr to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 545..571

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

                                                  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

                                                              if($request->filled('min_id')) {
                                                                  $replies = $status->comments()
                                                                  ->whereNull('reblog_of_id')
                                                                  ->whereIn('scope', $scope)
                                                                  ->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 hr to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 166..174

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

                                                  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

                                                              if($request->filled('max_id')) {
                                                                  $replies = $status->comments()
                                                                  ->whereNull('reblog_of_id')
                                                                  ->whereIn('scope', $scope)
                                                                  ->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
                                                  Severity: Major
                                                  Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 hr to fix
                                                  app/Http/Controllers/PublicApiController.php on lines 157..165

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

                                                  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