pixelfed/pixelfed

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

Summary

Maintainability
F
2 wks
Test Coverage

File DirectMessageController.php has 796 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers;

use Auth, Cache;
Severity: Major
Found in app/Http/Controllers/DirectMessageController.php - About 1 day to fix

    Method browse has 253 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function browse(Request $request)
        {
            $this->validate($request, [
                'a' => 'nullable|string|in:inbox,sent,filtered',
                'page' => 'nullable|integer|min:1|max:99'
    Severity: Major
    Found in app/Http/Controllers/DirectMessageController.php - About 1 day to fix

      Method mediaUpload has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function mediaUpload(Request $request)
          {
              $this->validate($request, [
                  'file'      => function() {
                      return [
      Severity: Major
      Found in app/Http/Controllers/DirectMessageController.php - About 3 hrs to fix

        Method create has 88 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function create(Request $request)
            {
                $this->validate($request, [
                    'to_id' => 'required',
                    'message' => 'required|string|min:1|max:500',
        Severity: Major
        Found in app/Http/Controllers/DirectMessageController.php - About 3 hrs to fix

          Method thread has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function thread(Request $request)
              {
                  $this->validate($request, [
                      'pid' => 'required'
                  ]);
          Severity: Major
          Found in app/Http/Controllers/DirectMessageController.php - About 3 hrs to fix

            Method delete has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function delete(Request $request)
                {
                    $this->validate($request, [
                        'id' => 'required'
                    ]);
            Severity: Major
            Found in app/Http/Controllers/DirectMessageController.php - About 2 hrs to fix

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

                  public function browse(Request $request)
                  {
                      $this->validate($request, [
                          'a' => 'nullable|string|in:inbox,sent,filtered',
                          'page' => 'nullable|integer|min:1|max:99'
              Severity: Minor
              Found in app/Http/Controllers/DirectMessageController.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 composeLookup has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function composeLookup(Request $request)
                  {
                      $this->validate($request, [
                          'q' => 'required|string|min:2|max:50',
                          'remote' => 'nullable',
              Severity: Minor
              Found in app/Http/Controllers/DirectMessageController.php - About 1 hr to fix

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

                    public function remoteDeliver($dm)
                    {
                        $profile = $dm->author;
                        $url = $dm->recipient->sharedInbox ?? $dm->recipient->inbox_url;
                
                
                Severity: Minor
                Found in app/Http/Controllers/DirectMessageController.php - About 1 hr to fix

                  Function create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function create(Request $request)
                      {
                          $this->validate($request, [
                              'to_id' => 'required',
                              'message' => 'required|string|min:1|max:500',
                  Severity: Minor
                  Found in app/Http/Controllers/DirectMessageController.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 mediaUpload has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function mediaUpload(Request $request)
                      {
                          $this->validate($request, [
                              'file'      => function() {
                                  return [
                  Severity: Minor
                  Found in app/Http/Controllers/DirectMessageController.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 composeLookup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function composeLookup(Request $request)
                      {
                          $this->validate($request, [
                              'q' => 'required|string|min:2|max:50',
                              'remote' => 'nullable',
                  Severity: Minor
                  Found in app/Http/Controllers/DirectMessageController.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 delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function delete(Request $request)
                      {
                          $this->validate($request, [
                              'id' => 'required'
                          ]);
                  Severity: Minor
                  Found in app/Http/Controllers/DirectMessageController.php - About 35 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

                  Avoid too many return statements within this method.
                  Open

                                          return $q->offset($page * 8 - 8);
                  Severity: Major
                  Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return [
                                    'id' => (string) $s->id,
                                    'hidden' => (bool) $s->is_hidden,
                                    'isAuthor' => $uid == $s->from_id,
                                    'type'  => $s->type,
                    Severity: Major
                    Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

                                            return $r->from_id !== $profile ? [
                                                'id' => (string) $r->from_id,
                                                'name' => $r->author->name,
                                                'username' => $r->author->username,
                                                'avatar' => $r->author->avatarUrl(),
                        Severity: Major
                        Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                  return $q->offset($page * 8 - 8);
                          Severity: Major
                          Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

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

                              Avoid too many return statements within this method.
                              Open

                                                  return $r->from_id !== $profile ? [
                                                      'id' => (string) $r->from_id,
                                                      'name' => $r->author->name,
                                                      'username' => $r->author->username,
                                                      'avatar' => $r->author->avatarUrl(),
                              Severity: Major
                              Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                        return $q->offset($page * 8 - 8);
                                Severity: Major
                                Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return $r->from_id !== $profile ? [
                                                          'id' => (string) $r->from_id,
                                                          'name' => $r->author->name,
                                                          'username' => $r->author->username,
                                                          'avatar' => $r->author->avatarUrl(),
                                  Severity: Major
                                  Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return response()->json($w, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
                                    Severity: Major
                                    Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                          return $r->from_id !== $profile ? [
                                                              'id' => (string) $r->from_id,
                                                              'name' => $r->author->name,
                                                              'username' => $r->author->username,
                                                              'avatar' => $r->author->avatarUrl(),
                                      Severity: Major
                                      Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                                return $q->offset($page * 8 - 8);
                                        Severity: Major
                                        Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                              return $r->from_id !== $profile ? [
                                                                  'id' => (string) $r->from_id,
                                                                  'name' => $r->author->name,
                                                                  'username' => $r->author->username,
                                                                  'avatar' => $r->author->avatarUrl(),
                                          Severity: Major
                                          Found in app/Http/Controllers/DirectMessageController.php - About 30 mins to fix

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

                                                            $dms = DirectMessage::select('id', 'type', 'to_id', 'from_id', 'id', 'status_id', 'is_hidden', 'meta', 'created_at', 'read_at')
                                                            ->whereFromId($profile)
                                                            ->with(['author','status'])
                                                            ->orderBy('id', 'desc')
                                                            ->when($page, function($q, $page) {
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 5 other locations - About 1 day to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 55..92
                                            app/Http/Controllers/DirectMessageController.php on lines 136..173
                                            app/Http/Controllers/DirectMessageController.php on lines 177..214
                                            app/Http/Controllers/DirectMessageController.php on lines 218..254
                                            app/Http/Controllers/DirectMessageController.php on lines 258..295

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

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

                                                            $dms = DirectMessage::select('id', 'type', 'to_id', 'from_id', 'id', 'status_id', 'is_hidden', 'meta', 'created_at', 'read_at')
                                                            ->whereToId($profile)
                                                            ->with(['author','status'])
                                                            ->whereIsHidden(true)
                                                            ->orderBy('id', 'desc')
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 5 other locations - About 1 day to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 55..92
                                            app/Http/Controllers/DirectMessageController.php on lines 96..132
                                            app/Http/Controllers/DirectMessageController.php on lines 177..214
                                            app/Http/Controllers/DirectMessageController.php on lines 218..254
                                            app/Http/Controllers/DirectMessageController.php on lines 258..295

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

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

                                                            $dms = DirectMessage::selectRaw('*, max(created_at) as createdAt')
                                                            ->whereToId($profile)
                                                            ->with(['author','status'])
                                                            ->whereIsHidden(false)
                                                            ->groupBy('from_id')
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 5 other locations - About 1 day to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 55..92
                                            app/Http/Controllers/DirectMessageController.php on lines 96..132
                                            app/Http/Controllers/DirectMessageController.php on lines 136..173
                                            app/Http/Controllers/DirectMessageController.php on lines 218..254
                                            app/Http/Controllers/DirectMessageController.php on lines 258..295

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

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

                                                            $dms = DirectMessage::selectRaw('*, max(created_at) as createdAt')
                                                            ->whereFromId($profile)
                                                            ->with(['author','status'])
                                                            ->groupBy('to_id')
                                                            ->orderBy('createdAt', 'desc')
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 5 other locations - About 1 day to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 55..92
                                            app/Http/Controllers/DirectMessageController.php on lines 96..132
                                            app/Http/Controllers/DirectMessageController.php on lines 136..173
                                            app/Http/Controllers/DirectMessageController.php on lines 177..214
                                            app/Http/Controllers/DirectMessageController.php on lines 258..295

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

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

                                                            $dms = DirectMessage::select('id', 'type', 'to_id', 'from_id', 'id', 'status_id', 'is_hidden', 'meta', 'created_at', 'read_at')
                                                            ->whereToId($profile)
                                                            ->with(['author','status'])
                                                            ->whereIsHidden(false)
                                                            ->when($page, function($q, $page) {
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 5 other locations - About 1 day to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 96..132
                                            app/Http/Controllers/DirectMessageController.php on lines 136..173
                                            app/Http/Controllers/DirectMessageController.php on lines 177..214
                                            app/Http/Controllers/DirectMessageController.php on lines 218..254
                                            app/Http/Controllers/DirectMessageController.php on lines 258..295

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

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

                                                            $dms = DirectMessage::selectRaw('*, max(created_at) as createdAt')
                                                            ->whereToId($profile)
                                                            ->with(['author','status'])
                                                            ->whereIsHidden(true)
                                                            ->groupBy('from_id')
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 5 other locations - About 1 day to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 55..92
                                            app/Http/Controllers/DirectMessageController.php on lines 96..132
                                            app/Http/Controllers/DirectMessageController.php on lines 136..173
                                            app/Http/Controllers/DirectMessageController.php on lines 177..214
                                            app/Http/Controllers/DirectMessageController.php on lines 218..254

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

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

                                                    if(config_cache('pixelfed.enforce_account_limit') == true) {
                                                        $size = Cache::remember($user->storageUsedKey(), now()->addDays(3), function() use($user) {
                                                            return Media::whereUserId($user->id)->sum('size') / 1000;
                                                        });
                                                        $limit = (int) config_cache('pixelfed.max_account_size');
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 4 other locations - About 1 hr to fix
                                            app/Http/Controllers/Api/ApiV1Controller.php on lines 1757..1765
                                            app/Http/Controllers/Api/ApiV1Controller.php on lines 1974..1982
                                            app/Http/Controllers/Api/ApiV2Controller.php on lines 249..257
                                            app/Http/Controllers/ComposeController.php on lines 87..95

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 119.

                                            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($min_id) {
                                                        $res = DirectMessage::select('*')
                                                        ->where('id', '>', $min_id)
                                                        ->where(function($q) use($pid,$uid) {
                                                            return $q->where([['from_id',$pid],['to_id',$uid]
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 1 other location - About 1 hr to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 431..449

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

                                            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

                                                    } else if ($max_id) {
                                                        $res = DirectMessage::select('*')
                                                        ->where('id', '<', $max_id)
                                                        ->where(function($q) use($pid,$uid) {
                                                            return $q->where([['from_id',$pid],['to_id',$uid]
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 1 other location - About 1 hr to fix
                                            app/Http/Controllers/DirectMessageController.php on lines 421..449

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

                                            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(filter_var($msg, FILTER_VALIDATE_URL)) {
                                                        if(Helpers::validateUrl($msg)) {
                                                            $dm->type = 'link';
                                                            $dm->meta = [
                                                                'domain' => parse_url($msg, PHP_URL_HOST),
                                            Severity: Major
                                            Found in app/Http/Controllers/DirectMessageController.php and 1 other location - About 1 hr to fix
                                            app/Util/ActivityPub/Inbox.php on lines 489..499

                                            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($recipient->domain == null && $hidden == false && !$nf) {
                                                        $notification = new Notification();
                                                        $notification->profile_id = $recipient->id;
                                                        $notification->actor_id = $profile->id;
                                                        $notification->action = 'dm';
                                            Severity: Minor
                                            Found in app/Http/Controllers/DirectMessageController.php and 1 other location - About 55 mins to fix
                                            app/Util/ActivityPub/Inbox.php on lines 507..515

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 99.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            There are no issues that match your filters.

                                            Category
                                            Status