pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

Method settingsApiUpdatePlatformType has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function settingsApiUpdatePlatformType($request)
    {
        $this->validate($request, [
            'allow_app_registration' => 'required',
            'app_registration_rate_limit_attempts' => 'required|integer|min:1',
Severity: Major
Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 2 hrs to fix

    Method comment has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function comment(Request $request)
        {
            abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
            $this->validate($request, [
                'sid' => 'required',
    Severity: Major
    Found in app/Http/Controllers/StoryComposeController.php - About 2 hrs to fix

      File home.blade.php has 266 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      @extends('admin.partial.template-full')
      
      @section('section')
      <div class="title d-flex justify-content-between align-items-center">
          <h3 class="font-weight-bold">Users</h3>
      Severity: Minor
      Found in resources/views/admin/users/home.blade.php - About 2 hrs to fix

        Method handleFollowActivity has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function handleFollowActivity()
            {
                $actor = $this->actorFirstOrCreate($this->payload['actor']);
                $target = $this->actorFirstOrCreate($this->payload['object']);
                if(!$actor || !$target) {
        Severity: Major
        Found in app/Util/ActivityPub/Inbox.php - About 2 hrs to fix

          Method getInstancesApi has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getInstancesApi(Request $request)
              {
                  $this->validate($request, [
                      'filter' => [
                          'nullable',
          Severity: Major
          Found in app/Http/Controllers/Admin/AdminInstanceController.php - About 2 hrs to fix

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

                public function transform(Profile $profile)
                {
                    if (! $profile) {
                        return [];
                    }
            Severity: Major
            Found in app/Transformer/Api/AccountTransformer.php - About 2 hrs to fix

              Helpers has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Helpers
              {
                  public static function validateObject($data)
                  {
                      $verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject', 'Undo', 'Tombstone'];
              Severity: Minor
              Found in app/Util/ActivityPub/Helpers.php - About 2 hrs to fix

                Method unlinkRemoveMedia has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function unlinkRemoveMedia($status)
                    {
                        Media::whereStatusId($status->id)
                            ->get()
                            ->each(function ($media) {
                Severity: Major
                Found in app/Jobs/StatusPipeline/StatusDelete.php - About 2 hrs to fix

                  Method handle has 58 lines of code (exceeds 25 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: Major
                  Found in app/Jobs/FollowPipeline/FollowServiceWarmCache.php - About 2 hrs to fix

                    Method remoteToCloud has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function remoteToCloud($media)
                        {
                            $url = $media->remote_url;
                    
                            if (! Helpers::validateUrl($url)) {
                    Severity: Major
                    Found in app/Services/MediaStorageService.php - About 2 hrs to fix

                      Method get has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function get($domain)
                          {
                              $version = config('pixelfed.version');
                              $appUrl = config('app.url');
                              $headers = [
                      Severity: Major
                      Found in app/Services/NodeinfoService.php - About 2 hrs to fix

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

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

                          Method homeUpdate has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function homeUpdate(Request $request)
                              {
                                  $this->validate($request, [
                                      'name'    => 'nullable|string|max:'.config('pixelfed.max_name_length'),
                                      'bio'     => 'nullable|string|max:'.config('pixelfed.max_bio_length'),
                          Severity: Major
                          Found in app/Http/Controllers/Settings/HomeSettings.php - About 2 hrs to fix

                            Method handleUser has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function handleUser($user)
                                {
                                    if(in_array($user->status, ['deleted', 'delete'])) {
                                        return;
                                    }
                            Severity: Major
                            Found in app/Observers/UserObserver.php - About 2 hrs to fix

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

                                  public function handle()
                                  {
                                      $this->info('Creating a new user...');
                              
                                      $o = $this->options();
                              Severity: Major
                              Found in app/Console/Commands/UserCreate.php - About 2 hrs to fix

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

                                    public function handleNoteCreate()
                                    {
                                        $activity = $this->payload['object'];
                                        $actor = $this->actorFirstOrCreate($this->payload['actor']);
                                        if(!$actor || $actor->domain == null) {
                                Severity: Minor
                                Found in app/Util/ActivityPub/Inbox.php - About 2 hrs to fix

                                Cognitive Complexity

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

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

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

                                Further reading

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

                                    public static function getMinMastodon($id = false, $start = 0, $limit = 10)
                                    {
                                        $ids = self::getRankedMinId($id, $start, $limit);
                                
                                        if (empty($ids)) {
                                Severity: Minor
                                Found in app/Services/NotificationService.php - About 2 hrs to fix

                                Cognitive Complexity

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

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

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

                                Further reading

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

                                    public static function handleImmediateAttributes(Status $status, $attributes)
                                    {
                                        if(isset($attributes['status'])) {
                                            $cleaned = Purify::clean($attributes['status']);
                                            $status->caption = $cleaned;
                                Severity: Minor
                                Found in app/Services/Status/UpdateStatusService.php - About 2 hrs to fix

                                Cognitive Complexity

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

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

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

                                Further reading

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

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

                                Cognitive Complexity

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

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

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

                                Further reading

                                Function 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/ApiV2Controller.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

                                Severity
                                Category
                                Status
                                Source
                                Language