pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

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

File web.php has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofactor', 'localization'])->group(function () {
    Route::get('/', 'SiteController@home')->name('timeline.personal');
    Route::redirect('/home', '/')->name('home');
Severity: Minor
Found in routes/web.php - About 4 hrs to fix

    Method selfCarousel has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function selfCarousel(Request $request)
        {
            abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
            $pid = $request->user()->profile_id;
    
    
    Severity: Major
    Found in app/Http/Controllers/Stories/StoryApiV1Controller.php - About 3 hrs to fix

      Method carousel has 99 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function carousel(Request $request)
          {
              abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
              $pid = $request->user()->profile_id;
      
      
      Severity: Major
      Found in app/Http/Controllers/Stories/StoryApiV1Controller.php - About 3 hrs to fix

        Method handleStoryReplyActivity has 98 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function handleStoryReplyActivity()
            {
                if(!isset(
                    $this->payload['actor'],
                    $this->payload['id'],
        Severity: Major
        Found in app/Util/ActivityPub/Inbox.php - About 3 hrs to fix

          Method handleStoryReactionActivity has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handleStoryReactionActivity()
              {
                  if(!isset(
                      $this->payload['actor'],
                      $this->payload['id'],
          Severity: Major
          Found in app/Util/ActivityPub/Inbox.php - About 3 hrs to fix

            Method checkPermissions has 98 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function checkPermissions($request, $abortOnFail = true)
                {
                    $user = $request->user();
            
                    if($abortOnFail) {
            Severity: Major
            Found in app/Http/Controllers/ImportPostController.php - About 3 hrs to fix

              Method handle has 98 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function handle()
                  {
                      if(!config('import.instagram.enabled')) {
                          return;
                      }
              Severity: Major
              Found in app/Console/Commands/TransformImports.php - About 3 hrs to fix

                Method storeSettings has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  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

                    Status has 31 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Status extends Model
                    {
                        use HasSnowflakePrimary, SoftDeletes;
                    
                        /**
                    Severity: Minor
                    Found in app/Status.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

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

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

                          Method moderatePost has 94 lines of code (exceeds 25 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: Major
                          Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php - About 3 hrs to fix

                            Function handleCreateActivity has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function handleCreateActivity()
                                {
                                    $activity = $this->payload['object'];
                                    if(config('autospam.live_filters.enabled')) {
                                        $filters = config('autospam.live_filters.filters');
                            Severity: Minor
                            Found in app/Util/ActivityPub/Inbox.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 get has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function get()
                                {
                                    return [
                                        1 => [
                                            "id" => 1,
                            Severity: Major
                            Found in app/Util/Media/License.php - About 3 hrs to fix

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

                                  public function handleUndoActivity()
                                  {
                                      $actor = $this->payload['actor'];
                                      $profile = self::actorFirstOrCreate($actor);
                                      $obj = $this->payload['object'];
                              Severity: Major
                              Found in app/Util/ActivityPub/Inbox.php - About 3 hrs to fix

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

                                    public function reportsHandleSpamAction($appeal, $action)
                                    {
                                        $meta = json_decode($appeal->meta);
                                
                                        if ($action == 'mark-read') {
                                Severity: Major
                                Found in app/Http/Controllers/Admin/AdminReportController.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

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

                                        public function instance(Request $request)
                                        {
                                            $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);
                                    Severity: Major
                                    Found in app/Http/Controllers/Api/ApiV2Controller.php - About 3 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language