pixelfed/pixelfed

View on GitHub
app/Http/Controllers/Api/ApiV1Controller.php

Summary

Maintainability
F
2 mos
Test Coverage

File ApiV1Controller.php has 3183 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers\Api;

use App\Avatar;
Severity: Major
Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 wk to fix

    Function accountUpdateCredentials has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

        public function accountUpdateCredentials(Request $request)
        {
            abort_if(! $request->user() || ! $request->user()->token(), 403);
            abort_unless($request->user()->tokenCan('write'), 403);
    
    
    Severity: Minor
    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 day 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 timelinePublic has 234 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function timelinePublic(Request $request)
        {
            $this->validate($request, [
                'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
                'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
    Severity: Major
    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 day to fix

      ApiV1Controller has 64 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ApiV1Controller extends Controller
      {
          protected $fractal;
      
          const PF_API_ENTITY_KEY = '_pe';
      Severity: Major
      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 day to fix

        Method timelineHome has 223 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function timelineHome(Request $request)
            {
                abort_if(! $request->user() || ! $request->user()->token(), 403);
                abort_unless($request->user()->tokenCan('read'), 403);
        
        
        Severity: Major
        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 day to fix

          Method accountUpdateCredentials has 205 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function accountUpdateCredentials(Request $request)
              {
                  abort_if(! $request->user() || ! $request->user()->token(), 403);
                  abort_unless($request->user()->tokenCan('write'), 403);
          
          
          Severity: Major
          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 day to fix

            Function statusCreate has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

                public function statusCreate(Request $request)
                {
                    abort_if(! $request->user() || ! $request->user()->token(), 403);
                    abort_unless($request->user()->tokenCan('write'), 403);
            
            
            Severity: Minor
            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 7 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 statusCreate has 177 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function statusCreate(Request $request)
                {
                    abort_if(! $request->user() || ! $request->user()->token(), 403);
                    abort_unless($request->user()->tokenCan('write'), 403);
            
            
            Severity: Major
            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 7 hrs to fix

              Function timelinePublic has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function timelinePublic(Request $request)
                  {
                      $this->validate($request, [
                          'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
                          'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
              Severity: Minor
              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 5 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 timelineHome has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function timelineHome(Request $request)
                  {
                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                      abort_unless($request->user()->tokenCan('read'), 403);
              
              
              Severity: Minor
              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 5 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 mediaUploadV2 has 110 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function mediaUploadV2(Request $request)
                  {
                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                      abort_unless($request->user()->tokenCan('write'), 403);
              
              
              Severity: Major
              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 4 hrs to fix

                Function statusFavouritedBy has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function statusFavouritedBy(Request $request, $id)
                    {
                        abort_if(! $request->user() || ! $request->user()->token(), 403);
                        abort_unless($request->user()->tokenCan('read'), 403);
                
                
                Severity: Minor
                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 4 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 statusRebloggedBy has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function statusRebloggedBy(Request $request, $id)
                    {
                        abort_if(! $request->user() || ! $request->user()->token(), 403);
                        abort_unless($request->user()->tokenCan('read'), 403);
                
                
                Severity: Minor
                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 4 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 timelineHashtag has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function timelineHashtag(Request $request, $hashtag)
                    {
                        abort_if(! $request->user() || ! $request->user()->token(), 403);
                        abort_unless($request->user()->tokenCan('read'), 403);
                
                
                Severity: Major
                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

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

                      public function mediaUpload(Request $request)
                      {
                          abort_if(! $request->user() || ! $request->user()->token(), 403);
                          abort_unless($request->user()->tokenCan('write'), 403);
                  
                  
                  Severity: Major
                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

                    Method accountNotifications has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function accountNotifications(Request $request)
                        {
                            abort_if(! $request->user() || ! $request->user()->token(), 403);
                            abort_unless($request->user()->tokenCan('read'), 403);
                    
                    
                    Severity: Major
                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

                      Function accountFollowingById has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function accountFollowingById(Request $request, $id)
                          {
                              abort_if(! $request->user() || ! $request->user()->token(), 403);
                              abort_unless($request->user()->tokenCan('read'), 403);
                      
                      
                      Severity: Minor
                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 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 accountFollowersById has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function accountFollowersById(Request $request, $id)
                          {
                              abort_if(! $request->user() || ! $request->user()->token(), 403);
                              abort_unless($request->user()->tokenCan('read'), 403);
                      
                      
                      Severity: Minor
                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 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 accountStatusesById has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function accountStatusesById(Request $request, $id)
                          {
                              abort_if(! $request->user() || ! $request->user()->token(), 403);
                              abort_unless($request->user()->tokenCan('read'), 403);
                      
                      
                      Severity: Major
                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

                        Method accountFollowersById has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function accountFollowersById(Request $request, $id)
                            {
                                abort_if(! $request->user() || ! $request->user()->token(), 403);
                                abort_unless($request->user()->tokenCan('read'), 403);
                        
                        
                        Severity: Major
                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

                          Method accountFollowingById has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function accountFollowingById(Request $request, $id)
                              {
                                  abort_if(! $request->user() || ! $request->user()->token(), 403);
                                  abort_unless($request->user()->tokenCan('read'), 403);
                          
                          
                          Severity: Major
                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

                            Method statusFavouritedBy has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function statusFavouritedBy(Request $request, $id)
                                {
                                    abort_if(! $request->user() || ! $request->user()->token(), 403);
                                    abort_unless($request->user()->tokenCan('read'), 403);
                            
                            
                            Severity: Major
                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

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

                                  public function statusReplies(Request $request, $id)
                                  {
                                      abort_if(! $request->user(), 403);
                              
                                      $this->validate($request, [
                              Severity: Major
                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

                                Method statusRebloggedBy has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function statusRebloggedBy(Request $request, $id)
                                    {
                                        abort_if(! $request->user() || ! $request->user()->token(), 403);
                                        abort_unless($request->user()->tokenCan('read'), 403);
                                
                                
                                Severity: Major
                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

                                  Method accountBlockById has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function accountBlockById(Request $request, $id)
                                      {
                                          abort_if(! $request->user() || ! $request->user()->token(), 403);
                                          abort_unless($request->user()->tokenCan('write'), 403);
                                  
                                  
                                  Severity: Major
                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

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

                                        public function instance(Request $request)
                                        {
                                            $res = Cache::remember('api:v1:instance-data-response-v1', 1800, function () {
                                                $contact = Cache::remember('api:v1:instance-data:contact', 604800, function () {
                                                    if (config_cache('instance.admin.pid')) {
                                    Severity: Major
                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

                                      Method accountFollowById has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function accountFollowById(Request $request, $id)
                                          {
                                              abort_if(! $request->user() || ! $request->user()->token(), 403);
                                              abort_unless($request->user()->tokenCan('follow'), 403);
                                      
                                      
                                      Severity: Major
                                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

                                        Method conversations has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public function conversations(Request $request)
                                            {
                                                abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                abort_unless($request->user()->tokenCan('read'), 403);
                                        
                                        
                                        Severity: Major
                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

                                          Function mediaUploadV2 has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function mediaUploadV2(Request $request)
                                              {
                                                  abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                  abort_unless($request->user()->tokenCan('write'), 403);
                                          
                                          
                                          Severity: Minor
                                          Found in app/Http/Controllers/Api/ApiV1Controller.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 statusContext has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              public function statusContext(Request $request, $id)
                                              {
                                                  abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                  abort_unless($request->user()->tokenCan('read'), 403);
                                          
                                          
                                          Severity: Major
                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

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

                                                public function statusContext(Request $request, $id)
                                                {
                                                    abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                    abort_unless($request->user()->tokenCan('read'), 403);
                                            
                                            
                                            Severity: Minor
                                            Found in app/Http/Controllers/Api/ApiV1Controller.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 bookmarks has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                public function bookmarks(Request $request)
                                                {
                                                    abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                    abort_unless($request->user()->tokenCan('read'), 403);
                                            
                                            
                                            Severity: Minor
                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                  public function accountUnfollowById(Request $request, $id)
                                                  {
                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                      abort_unless($request->user()->tokenCan('follow'), 403);
                                              
                                              
                                              Severity: Minor
                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

                                                Method accountFavourites has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    public function accountFavourites(Request $request)
                                                    {
                                                        abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                        abort_unless($request->user()->tokenCan('read'), 403);
                                                
                                                
                                                Severity: Minor
                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

                                                  Method statusFavouriteById has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      public function statusFavouriteById(Request $request, $id)
                                                      {
                                                          abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                          abort_unless($request->user()->tokenCan('write'), 403);
                                                  
                                                  
                                                  Severity: Minor
                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

                                                    Function mediaUpload has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function mediaUpload(Request $request)
                                                        {
                                                            abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                            abort_unless($request->user()->tokenCan('write'), 403);
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in app/Http/Controllers/Api/ApiV1Controller.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 timelineHashtag has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function timelineHashtag(Request $request, $hashtag)
                                                        {
                                                            abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                            abort_unless($request->user()->tokenCan('read'), 403);
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in app/Http/Controllers/Api/ApiV1Controller.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 accountStatusesById has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function accountStatusesById(Request $request, $id)
                                                        {
                                                            abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                            abort_unless($request->user()->tokenCan('read'), 403);
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in app/Http/Controllers/Api/ApiV1Controller.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 accountMuteById has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                        public function accountMuteById(Request $request, $id)
                                                        {
                                                            abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                            abort_unless($request->user()->tokenCan('write'), 403);
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                          public function accountBlocks(Request $request)
                                                          {
                                                              abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                              abort_unless($request->user()->tokenCan('read'), 403);
                                                      
                                                      
                                                      Severity: Minor
                                                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                            public function accountFollowRequestAccept(Request $request, $id)
                                                            {
                                                                abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                abort_unless($request->user()->tokenCan('follow'), 403);
                                                        
                                                        
                                                        Severity: Minor
                                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                              public function accountMutes(Request $request)
                                                              {
                                                                  abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                  abort_unless($request->user()->tokenCan('read'), 403);
                                                          
                                                          
                                                          Severity: Minor
                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

                                                            Method statusShare has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                                            Open

                                                                public function statusShare(Request $request, $id)
                                                                {
                                                                    abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                    abort_unless($request->user()->tokenCan('write'), 403);
                                                            
                                                            
                                                            Severity: Minor
                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                                  public function statusById(Request $request, $id)
                                                                  {
                                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                      abort_unless($request->user()->tokenCan('read'), 403);
                                                              
                                                              
                                                              Severity: Minor
                                                              Found in app/Http/Controllers/Api/ApiV1Controller.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 accountNotifications has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                                              Open

                                                                  public function accountNotifications(Request $request)
                                                                  {
                                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                      abort_unless($request->user()->tokenCan('read'), 403);
                                                              
                                                              
                                                              Severity: Minor
                                                              Found in app/Http/Controllers/Api/ApiV1Controller.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 mediaUpdate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                                              Open

                                                                  public function mediaUpdate(Request $request, $id)
                                                                  {
                                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                      abort_unless($request->user()->tokenCan('write'), 403);
                                                              
                                                              
                                                              Severity: Minor
                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                                    public function discoverAccountsPopular(Request $request)
                                                                    {
                                                                        abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                        abort_unless($request->user()->tokenCan('read'), 403);
                                                                
                                                                
                                                                Severity: Minor
                                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

                                                                  Function accountFollowById has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                                  Open

                                                                      public function accountFollowById(Request $request, $id)
                                                                      {
                                                                          abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                          abort_unless($request->user()->tokenCan('follow'), 403);
                                                                  
                                                                  
                                                                  Severity: Minor
                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.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 statusById has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                  Open

                                                                      public function statusById(Request $request, $id)
                                                                      {
                                                                          abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                          abort_unless($request->user()->tokenCan('read'), 403);
                                                                  
                                                                  
                                                                  Severity: Minor
                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

                                                                    Method accountSearch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                    Open

                                                                        public function accountSearch(Request $request)
                                                                        {
                                                                            abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                            abort_unless($request->user()->tokenCan('read'), 403);
                                                                    
                                                                    
                                                                    Severity: Minor
                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                                          public function apps(Request $request)
                                                                          {
                                                                              abort_if(! (bool) config_cache('pixelfed.oauth_enabled'), 404);
                                                                      
                                                                              $this->validate($request, [
                                                                      Severity: Minor
                                                                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                                            public function statusReplies(Request $request, $id)
                                                                            {
                                                                                abort_if(! $request->user(), 403);
                                                                        
                                                                                $this->validate($request, [
                                                                        Severity: Minor
                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.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 statusShare has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                            public function statusShare(Request $request, $id)
                                                                            {
                                                                                abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                abort_unless($request->user()->tokenCan('write'), 403);
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.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 statusUnshare has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                        Open

                                                                            public function statusUnshare(Request $request, $id)
                                                                            {
                                                                                abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                abort_unless($request->user()->tokenCan('write'), 403);
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 hr to fix

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

                                                                              public function statusFavouriteById(Request $request, $id)
                                                                              {
                                                                                  abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                  abort_unless($request->user()->tokenCan('write'), 403);
                                                                          
                                                                          
                                                                          Severity: Minor
                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 45 mins to fix

                                                                          Cognitive Complexity

                                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                          A method's cognitive complexity is based on a few simple rules:

                                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                                          Further reading

                                                                          Consider simplifying this complex logical expression.
                                                                          Open

                                                                                          if (! $dm || empty($dm['last_status']) || ! isset($dm['accounts']) || ! count($dm['accounts']) || ! isset($dm['accounts'][0]) || ! isset($dm['accounts'][0]['id'])) {
                                                                                              return false;
                                                                                          }
                                                                          Severity: Major
                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 40 mins to fix

                                                                            Function accountBlockById has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                            Open

                                                                                public function accountBlockById(Request $request, $id)
                                                                                {
                                                                                    abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                    abort_unless($request->user()->tokenCan('write'), 403);
                                                                            
                                                                            
                                                                            Severity: Minor
                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.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 $this->json($res, 200, $headers);
                                                                            Severity: Major
                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

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

                                                                                Avoid too many return statements within this method.
                                                                                Open

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

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                                  return ['id' => $s['id']];
                                                                                  Severity: Major
                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

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

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                          return $account && isset($account['id']);
                                                                                      Severity: Major
                                                                                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

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

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

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

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                            return $account && isset($account['id']);
                                                                                            Severity: Major
                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

                                                                                                                  return isset($n['account'], $n['account']['id']);
                                                                                              Severity: Major
                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

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

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

                                                                                                              return [
                                                                                                                  'uri' => config('pixelfed.domain.app'),
                                                                                                                  'title' => config_cache('app.name'),
                                                                                                                  'short_description' => config_cache('app.short_description'),
                                                                                                                  'description' => config_cache('app.description'),
                                                                                                  Severity: Major
                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

                                                                                                                        return $status && isset($status['account']);
                                                                                                    Severity: Major
                                                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

                                                                                                                  return $napi ? AccountService::get($follower->following_id, true) : AccountService::getMastodon($follower->following_id, true);
                                                                                                      Severity: Major
                                                                                                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

                                                                                                                        return true;
                                                                                                        Severity: Major
                                                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                          return ['id' => $s['id']];
                                                                                                          Severity: Major
                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                            Avoid too many return statements within this method.
                                                                                                            Open

                                                                                                                        return $this->json($res, 200, ['Link' => $link]);
                                                                                                            Severity: Major
                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                              Avoid too many return statements within this method.
                                                                                                              Open

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

                                                                                                                Avoid too many return statements within this method.
                                                                                                                Open

                                                                                                                        return $this->json($res, 202);
                                                                                                                Severity: Major
                                                                                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                  Avoid too many return statements within this method.
                                                                                                                  Open

                                                                                                                              return $following->push($pid)->toArray();
                                                                                                                  Severity: Major
                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                    Avoid too many return statements within this method.
                                                                                                                    Open

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

                                                                                                                      Avoid too many return statements within this method.
                                                                                                                      Open

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

                                                                                                                        Avoid too many return statements within this method.
                                                                                                                        Open

                                                                                                                                            return $account && isset($account['id']);
                                                                                                                        Severity: Major
                                                                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                          Avoid too many return statements within this method.
                                                                                                                          Open

                                                                                                                                  return $this->json($res, 200, $headers);
                                                                                                                          Severity: Major
                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                            Avoid too many return statements within this method.
                                                                                                                            Open

                                                                                                                                                return $includeReblogs ? true : $s['reblog'] == null;
                                                                                                                            Severity: Major
                                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                              Avoid too many return statements within this method.
                                                                                                                              Open

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

                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                Open

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

                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                  Open

                                                                                                                                                  return $status['like_id'];
                                                                                                                                  Severity: Major
                                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                    Open

                                                                                                                                                return $this->json($res->toArray(), 200, $headers);
                                                                                                                                    Severity: Major
                                                                                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                      Open

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

                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                        Open

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

                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                          Open

                                                                                                                                                      return $napi ? AccountService::get($follower->profile_id, true) : AccountService::getMastodon($follower->profile_id, true);
                                                                                                                                          Severity: Major
                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                            Open

                                                                                                                                                            return $account && isset($account['id']);
                                                                                                                                            Severity: Major
                                                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                              Open

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

                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                Open

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

                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                  Open

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

                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                    Open

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

                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                      Open

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

                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                        Open

                                                                                                                                                                return $this->json($res, 200, $headers);
                                                                                                                                                        Severity: Major
                                                                                                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                          Open

                                                                                                                                                                              return $status && isset($status['account']);
                                                                                                                                                          Severity: Major
                                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                            Open

                                                                                                                                                                        return ['id' => $s['id']];
                                                                                                                                                            Severity: Major
                                                                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                              Open

                                                                                                                                                                      return $this->json($res->toArray(), 200, $headers);
                                                                                                                                                              Severity: Major
                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                                Open

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

                                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                                  Open

                                                                                                                                                                                  return $q->whereIsHidden(false)
                                                                                                                                                                                      ->where('to_id', $pid)
                                                                                                                                                                                      ->orWhere('from_id', $pid)
                                                                                                                                                                                      ->orderByDesc('status_id')
                                                                                                                                                                                      ->groupBy(['to_id', 'from_id']);
                                                                                                                                                                  Severity: Major
                                                                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.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/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                                      Open

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

                                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                                        Open

                                                                                                                                                                                    return ['id' => $s['id']];
                                                                                                                                                                        Severity: Major
                                                                                                                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                                          Open

                                                                                                                                                                                          return ! in_array($domain, $domainBlocks);
                                                                                                                                                                          Severity: Major
                                                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                                            Open

                                                                                                                                                                                            return $item['accounts'][0]['id'];
                                                                                                                                                                            Severity: Major
                                                                                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                                              Open

                                                                                                                                                                                                  return $post && isset($post['account'], $post['account']['id']) && ! in_array($post['account']['id'], $filters);
                                                                                                                                                                              Severity: Major
                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                                                Open

                                                                                                                                                                                                return $account && isset($account['id']);
                                                                                                                                                                                Severity: Major
                                                                                                                                                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                                                  Open

                                                                                                                                                                                                      return true;
                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                                                    Open

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

                                                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                                                      Open

                                                                                                                                                                                                      return $pe ? StatusService::get($i, false) : StatusService::getMastodon($i, false);
                                                                                                                                                                                      Severity: Major
                                                                                                                                                                                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                                                        Open

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

                                                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                                                          Open

                                                                                                                                                                                                          return ! in_array($profile['id'], $asf);
                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                                                            Open

                                                                                                                                                                                                                return $q->whereFromId($pid)->groupBy('to_id');
                                                                                                                                                                                            Severity: Major
                                                                                                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                                                              Open

                                                                                                                                                                                                              return ! in_array($profile['id'], $filters);
                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                                                                Open

                                                                                                                                                                                                                    return $max != $k;
                                                                                                                                                                                                Severity: Major
                                                                                                                                                                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                                                                  Open

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

                                                                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                                                                    Open

                                                                                                                                                                                                                    return ! in_array($i['account']['id'], $filters) && ! in_array($domain, $domainBlocks);
                                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                                                                      Open

                                                                                                                                                                                                                              return $q->where('id', $dir, $id);
                                                                                                                                                                                                      Severity: Major
                                                                                                                                                                                                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                                                                        Open

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

                                                                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                                                                          Open

                                                                                                                                                                                                                          return true;
                                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.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/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                                                                              Open

                                                                                                                                                                                                                                      return true;
                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                                                                                Open

                                                                                                                                                                                                                        return $this->json($res, 200, $headers);
                                                                                                                                                                                                                Severity: Major
                                                                                                                                                                                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                                                                                  Open

                                                                                                                                                                                                                                  return $account && isset($account['id']);
                                                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                                                                                    Open

                                                                                                                                                                                                                            return $this->json($res);
                                                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.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/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                                                                                        Open

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

                                                                                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                                                                                          Open

                                                                                                                                                                                                                                  return $this->json($res, 200, $headers);
                                                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                                                                                            Open

                                                                                                                                                                                                                                        return ! in_array($post->profile_id, $filters);
                                                                                                                                                                                                                            Severity: Major
                                                                                                                                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                                                                                              Open

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

                                                                                                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                                                                                                Open

                                                                                                                                                                                                                                                return true;
                                                                                                                                                                                                                                Severity: Major
                                                                                                                                                                                                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                                                                                                  Open

                                                                                                                                                                                                                                                  return ! FollowerService::follows($pid, $profile['id'], true);
                                                                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                                                                                                    Open

                                                                                                                                                                                                                                                return ['id' => $s['id']];
                                                                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                                                                                                      Open

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

                                                                                                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                                                                                                        Open

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

                                                                                                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                                                                                                          Open

                                                                                                                                                                                                                                                      return ['id' => $s['id']];
                                                                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                                                                                                            Open

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

                                                                                                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                                                                                                              Open

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

                                                                                                                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                                                                                                                Open

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

                                                                                                                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                                                                                                                  Open

                                                                                                                                                                                                                                                          return $this->json($ids);
                                                                                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                                                                                                                    Open

                                                                                                                                                                                                                                                                        return $q->whereToId($pid)->whereIsHidden(true);
                                                                                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                                                                                                                      Open

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

                                                                                                                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                                                                                                                        Open

                                                                                                                                                                                                                                                                            return true;
                                                                                                                                                                                                                                                        Severity: Major
                                                                                                                                                                                                                                                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                                                                                                                          Open

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

                                                                                                                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                                                                                                                            Open

                                                                                                                                                                                                                                                                    return $this->json($res->toArray(), 200, $headers);
                                                                                                                                                                                                                                                            Severity: Major
                                                                                                                                                                                                                                                            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                                                                                                                              Open

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

                                                                                                                                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                                                                                                                                Open

                                                                                                                                                                                                                                                                                        return FollowerService::follows($pid, $i['account']['id'], true);
                                                                                                                                                                                                                                                                Severity: Major
                                                                                                                                                                                                                                                                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                                                                                                                                  Open

                                                                                                                                                                                                                                                                                      return $min != $k;
                                                                                                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                                                                                                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                                                                                                                                    Open

                                                                                                                                                                                                                                                                                    return $post && isset($post['id']) && isset($post['account']) && isset($post['account']['id']);
                                                                                                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                                                                                                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                                                                                                                                      Open

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

                                                                                                                                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                                                                                                                                        Open

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

                                                                                                                                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                                                                                                                                          Open

                                                                                                                                                                                                                                                                                          return $i && isset($i['account'], $i['url']);
                                                                                                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                                                                                                          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 30 mins to fix

                                                                                                                                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                                                                                                                                            Open

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

                                                                                                                                                                                                                                                                              Function bookmarks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                                                                                                                              Open

                                                                                                                                                                                                                                                                                  public function bookmarks(Request $request)
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                                                                                                                                                                                                                      abort_unless($request->user()->tokenCan('read'), 403);
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              Severity: Minor
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 25 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 accountFollowRequestAccept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                                                                                                                              Open

                                                                                                                                                                                                                                                                                  public function accountFollowRequestAccept(Request $request, $id)
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                                                                                                                                                                                                                      abort_unless($request->user()->tokenCan('follow'), 403);
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              Severity: Minor
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 25 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

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

                                                                                                                                                                                                                                                                                  public function accountFollowersById(Request $request, $id)
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                                                                                                                                                                                                                      abort_unless($request->user()->tokenCan('read'), 403);
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 4 days to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 573..667

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                  public function accountFollowingById(Request $request, $id)
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                                                                                                                                                                                                                                                                                      abort_unless($request->user()->tokenCan('read'), 403);
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 4 days to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 472..565

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                          $res = Status::select(
                                                                                                                                                                                                                                                                                              'id',
                                                                                                                                                                                                                                                                                              'profile_id',
                                                                                                                                                                                                                                                                                              'type',
                                                                                                                                                                                                                                                                                              'visibility',
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 day to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 2474..2513

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                          $res = Status::select(
                                                                                                                                                                                                                                                                                              'id',
                                                                                                                                                                                                                                                                                              'profile_id',
                                                                                                                                                                                                                                                                                              'type',
                                                                                                                                                                                                                                                                                              'visibility',
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 day to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 2529..2567

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                          if (config('instance.timeline.network.cached')) {
                                                                                                                                                                                                                                                                                              Cache::remember('api:v1:timelines:network:cache_check', 10368000, function () {
                                                                                                                                                                                                                                                                                                  if (NetworkTimelineService::count() == 0) {
                                                                                                                                                                                                                                                                                                      NetworkTimelineService::warmCache(true, config('instance.timeline.network.cache_dropoff'));
                                                                                                                                                                                                                                                                                                  }
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 7 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 2731..2776

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                          if (config('instance.timeline.local.cached')) {
                                                                                                                                                                                                                                                                                              Cache::remember('api:v1:timelines:public:cache_check', 10368000, function () {
                                                                                                                                                                                                                                                                                                  if (PublicTimelineService::count() == 0) {
                                                                                                                                                                                                                                                                                                      PublicTimelineService::warmCache(true, 400);
                                                                                                                                                                                                                                                                                                  }
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 7 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 2684..2729

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      $ids = $ids->map(function ($profile) {
                                                                                                                                                                                                                                                                                          return AccountService::get($profile->id, true);
                                                                                                                                                                                                                                                                                      })
                                                                                                                                                                                                                                                                                          ->filter(function ($profile) {
                                                                                                                                                                                                                                                                                              return $profile && isset($profile['id'], $profile['locked']) && ! $profile['locked'];
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 7 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/DiscoverController.php on lines 400..419

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

                                                                                                                                                                                                                                                                              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 ($count == 0) {
                                                                                                                                                                                                                                                                                          $filterCount = UserFilter::whereUserId($pid)
                                                                                                                                                                                                                                                                                              ->whereFilterType('block')
                                                                                                                                                                                                                                                                                              ->get()
                                                                                                                                                                                                                                                                                              ->map(function ($rec) {
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 4 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 2149..2164

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

                                                                                                                                                                                                                                                                              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 ($count == 0) {
                                                                                                                                                                                                                                                                                          $filterCount = UserFilter::whereUserId($pid)
                                                                                                                                                                                                                                                                                              ->whereFilterType('mute')
                                                                                                                                                                                                                                                                                              ->get()
                                                                                                                                                                                                                                                                                              ->map(function ($rec) {
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 4 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 1107..1122

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      $res = $res->map(function ($like) use ($pid, $napi) {
                                                                                                                                                                                                                                                                                          $account = $napi ? AccountService::get($like->profile_id, true) : AccountService::getMastodon($like->profile_id, true);
                                                                                                                                                                                                                                                                                          if (! $account) {
                                                                                                                                                                                                                                                                                              return false;
                                                                                                                                                                                                                                                                                          }
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 3 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 3179..3193

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      $res = $res->map(function ($status) use ($pid, $napi) {
                                                                                                                                                                                                                                                                                          $account = $napi ? AccountService::get($status->profile_id, true) : AccountService::getMastodon($status->profile_id, true);
                                                                                                                                                                                                                                                                                          if (! $account) {
                                                                                                                                                                                                                                                                                              return false;
                                                                                                                                                                                                                                                                                          }
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 3 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 3280..3295

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      if ($author && $res->hasPages()) {
                                                                                                                                                                                                                                                                                          $links = '';
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                          if ($res->onFirstPage()) {
                                                                                                                                                                                                                                                                                              if ($res->nextPageUrl()) {
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 2 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 3157..3177

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      if ($author && $res->hasPages()) {
                                                                                                                                                                                                                                                                                          $links = '';
                                                                                                                                                                                                                                                                                          if ($res->onFirstPage()) {
                                                                                                                                                                                                                                                                                              if ($res->nextPageUrl()) {
                                                                                                                                                                                                                                                                                                  $links = '<'.$res->nextPageUrl().'>; rel="prev"';
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 2 hrs to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 3257..3278

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

                                                                                                                                                                                                                                                                              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/Api/ApiV1Controller.php and 4 other locations - About 1 hr to fix
                                                                                                                                                                                                                                                                              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
                                                                                                                                                                                                                                                                              app/Http/Controllers/DirectMessageController.php on lines 603..611

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                              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/Api/ApiV1Controller.php and 4 other locations - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 1757..1765
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV2Controller.php on lines 249..257
                                                                                                                                                                                                                                                                              app/Http/Controllers/ComposeController.php on lines 87..95
                                                                                                                                                                                                                                                                              app/Http/Controllers/DirectMessageController.php on lines 603..611

                                                                                                                                                                                                                                                                              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

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

                                                                                                                                                                                                                                                                                      $this->validate($request, [
                                                                                                                                                                                                                                                                                          'file.*' => [
                                                                                                                                                                                                                                                                                              'required_without:file',
                                                                                                                                                                                                                                                                                              'mimetypes:'.config_cache('pixelfed.media_types'),
                                                                                                                                                                                                                                                                                              'max:'.config_cache('pixelfed.max_photo_size'),
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV2Controller.php on lines 211..226

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

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

                                                                                                                                                                                                                                                                                          $rules = Cache::remember('api:v1:instance-data:rules', 604800, function () {
                                                                                                                                                                                                                                                                                              return config_cache('app.rules') ?
                                                                                                                                                                                                                                                                                                  collect(json_decode(config_cache('app.rules'), true))
                                                                                                                                                                                                                                                                                                      ->map(function ($rule, $key) {
                                                                                                                                                                                                                                                                                                          $id = $key + 1;
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 2 other locations - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV2Controller.php on lines 61..72
                                                                                                                                                                                                                                                                              app/Services/LandingService.php on lines 36..48

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

                                                                                                                                                                                                                                                                                          $contact = Cache::remember('api:v1:instance-data:contact', 604800, function () {
                                                                                                                                                                                                                                                                                              if (config_cache('instance.admin.pid')) {
                                                                                                                                                                                                                                                                                                  return AccountService::getMastodon(config_cache('instance.admin.pid'), true);
                                                                                                                                                                                                                                                                                              }
                                                                                                                                                                                                                                                                                              $admin = User::whereIsAdmin(true)->first();
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 2 other locations - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV2Controller.php on lines 51..59
                                                                                                                                                                                                                                                                              app/Services/LandingService.php on lines 25..34

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      $posts = $forYou->take(50)->map(function ($post) {
                                                                                                                                                                                                                                                                                          return StatusService::getMastodon($post);
                                                                                                                                                                                                                                                                                      })
                                                                                                                                                                                                                                                                                          ->filter(function ($post) use ($filters) {
                                                                                                                                                                                                                                                                                              return $post &&
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/InternalApiController.php on lines 76..86

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

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

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

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

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

                                                                                                                                                                                                                                                                              Refactorings

                                                                                                                                                                                                                                                                              Further Reading

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

                                                                                                                                                                                                                                                                                      if (config('costar.enabled') == true) {
                                                                                                                                                                                                                                                                                          $blockedKeywords = config('costar.keyword.block');
                                                                                                                                                                                                                                                                                          if ($blockedKeywords !== null && $request->status) {
                                                                                                                                                                                                                                                                                              $keywords = config('costar.keyword.block');
                                                                                                                                                                                                                                                                                              foreach ($keywords as $kw) {
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 2 other locations - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/ComposeController.php on lines 480..490
                                                                                                                                                                                                                                                                              app/Http/Controllers/ComposeController.php on lines 650..660

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      if ($status && isset($status['account'], $status['account']['acct']) && strpos($status['account']['acct'], '@') != -1) {
                                                                                                                                                                                                                                                                                          $domain = parse_url($status['account']['url'], PHP_URL_HOST);
                                                                                                                                                                                                                                                                                          abort_if(in_array($domain, InstanceService::getBannedDomains()), 404);
                                                                                                                                                                                                                                                                                      }
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 3031..3034

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      if ($status && isset($status['account'], $status['account']['acct']) && strpos($status['account']['acct'], '@') != -1) {
                                                                                                                                                                                                                                                                                          $domain = parse_url($status['account']['url'], PHP_URL_HOST);
                                                                                                                                                                                                                                                                                          abort_if(in_array($domain, InstanceService::getBannedDomains()), 404);
                                                                                                                                                                                                                                                                                      }
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 1335..1338

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

                                                                                                                                                                                                                                                                              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

                                                                                                                                                                                                                                                                                      if (! $author) {
                                                                                                                                                                                                                                                                                          if ($status->scope == 'private') {
                                                                                                                                                                                                                                                                                              abort_if(! FollowerService::follows($pid, $status->profile_id), 403);
                                                                                                                                                                                                                                                                                          } else {
                                                                                                                                                                                                                                                                                              abort_if(! in_array($status->scope, ['public', 'unlisted']), 403);
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 3235..3245

                                                                                                                                                                                                                                                                              Duplicated Code

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

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

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

                                                                                                                                                                                                                                                                              Tuning

                                                                                                                                                                                                                                                                              This issue has a mass of 103.

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

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

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

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

                                                                                                                                                                                                                                                                              Refactorings

                                                                                                                                                                                                                                                                              Further Reading

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

                                                                                                                                                                                                                                                                                      if (! $author) {
                                                                                                                                                                                                                                                                                          if ($status->scope == 'private') {
                                                                                                                                                                                                                                                                                              abort_if(! FollowerService::follows($pid, $status->profile_id), 403);
                                                                                                                                                                                                                                                                                          } else {
                                                                                                                                                                                                                                                                                              abort_if(! in_array($status->scope, ['public', 'unlisted']), 403);
                                                                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                                                                              Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
                                                                                                                                                                                                                                                                              app/Http/Controllers/Api/ApiV1Controller.php on lines 3135..3145

                                                                                                                                                                                                                                                                              Duplicated Code

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

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

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

                                                                                                                                                                                                                                                                              Tuning

                                                                                                                                                                                                                                                                              This issue has a mass of 103.

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

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

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

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

                                                                                                                                                                                                                                                                              Refactorings

                                                                                                                                                                                                                                                                              Further Reading

                                                                                                                                                                                                                                                                              There are no issues that match your filters.

                                                                                                                                                                                                                                                                              Category
                                                                                                                                                                                                                                                                              Status