pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

Method handleDirectMessage has 119 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handleDirectMessage()
    {
        $activity = $this->payload['object'];
        $actor = $this->actorFirstOrCreate($this->payload['actor']);
        $profile = Profile::whereNull('domain')
Severity: Major
Found in app/Util/ActivityPub/Inbox.php - About 4 hrs to fix

    Function userAdminAction has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        public function userAdminAction(Request $request)
        {
            abort_if(!$request->user() || !$request->user()->token(), 404);
    
            abort_unless($request->user()->is_admin == 1, 404);
    Severity: Minor
    Found in app/Http/Controllers/Api/AdminApiController.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 handleDirectMessage has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        public function handleDirectMessage()
        {
            $activity = $this->payload['object'];
            $actor = $this->actorFirstOrCreate($this->payload['actor']);
            $profile = Profile::whereNull('domain')
    Severity: Minor
    Found in app/Util/ActivityPub/Inbox.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 transform has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function transform(Status $status)
        {
    
            $mentions = $status->mentions->map(function ($mention) {
                $webfinger = $mention->emailUrl();
    Severity: Major
    Found in app/Transformer/ActivityPub/Verb/Note.php - About 4 hrs to fix

      File SearchApiV2Service.php has 356 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace App\Services;
      
      use App\Hashtag;
      Severity: Minor
      Found in app/Services/SearchApiV2Service.php - About 4 hrs to fix

        Method transform has 113 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function transform(Status $status)
            {
                $mentions = $status->mentions->map(function ($mention) {
                    $webfinger = $mention->emailUrl();
                    $name = Str::startsWith($webfinger, '@') ?
        Severity: Major
        Found in app/Transformer/ActivityPub/Verb/UpdateNote.php - About 4 hrs to fix

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

              public function directoryInitialData(Request $request)
              {
                  $res = [];
          
                  $res['countries'] = collect((new ISO3166)->all())->pluck('name');
          Severity: Major
          Found in app/Http/Controllers/Admin/AdminDirectoryController.php - About 4 hrs to fix

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

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

              Function handle has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function handle()
                  {
                      $id = $this->profileId;
              
                      if(Cache::has(FollowerService::FOLLOWERS_SYNC_KEY . $id) && Cache::has(FollowerService::FOLLOWING_SYNC_KEY . $id)) {
              Severity: Minor
              Found in app/Jobs/FollowPipeline/FollowServiceWarmCache.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 store has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function store(Request $request)
                  {
                      $this->validate($request, [
                          'caption' => 'nullable|string|max:'.config_cache('pixelfed.max_caption_length', 500),
                          'media.*' => 'required',
              Severity: Minor
              Found in app/Http/Controllers/ComposeController.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 moderatePost has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function moderatePost(Request $request, $id)
                  {
                      abort_if(! $request->user() || ! $request->user()->token(), 403);
                      abort_if($request->user()->is_admin != true, 403);
                      abort_unless($request->user()->tokenCan('admin:write'), 403);
              Severity: Minor
              Found in app/Http/Controllers/Api/ApiV1Dot1Controller.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 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

                File CuratedRegisterController.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace App\Http\Controllers;
                
                use Illuminate\Http\Request;
                Severity: Minor
                Found in app/Http/Controllers/CuratedRegisterController.php - About 4 hrs to fix

                  File Status.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace App;
                  
                  use Auth, Cache, Hashids, Storage;
                  Severity: Minor
                  Found in app/Status.php - About 4 hrs to fix

                    Method mediaUploadV2 has 109 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/ApiV2Controller.php - About 4 hrs to fix

                      File LiveStreamController.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      
                      namespace App\Http\Controllers;
                      
                      use Illuminate\Http\Request;
                      Severity: Minor
                      Found in app/Http/Controllers/LiveStreamController.php - About 4 hrs to fix

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

                            public function handle()
                            {
                                $profile = null;
                                $headers = $this->headers;
                                $payload = json_decode($this->payload, true, 8);
                        Severity: Minor
                        Found in app/Jobs/InboxPipeline/DeleteWorker.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 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 handle has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function handle()
                            {
                                if(!config('import.instagram.enabled')) {
                                    return;
                                }
                        Severity: Minor
                        Found in app/Console/Commands/TransformImports.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 buildListing has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function buildListing()
                            {
                                $res = config_cache('pixelfed.directory');
                                if ($res) {
                                    $res = is_string($res) ? json_decode($res, true) : $res;
                        Severity: Major
                        Found in app/Http/Controllers/PixelfedDirectoryController.php - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language