pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

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

    public function handle()
    {
        $ids = AccountStatService::getAllPostCountIncr();
        if(!$ids || !count($ids)) {
            return;
Severity: Minor
Found in app/Console/Commands/AccountPostCountStatUpdate.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 handle has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle()
    {
        $pid = $this->profileId;
        $type = $this->followType;

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

        public function handle()
        {
            $media = $this->media;
            $path = $media->media_path;
            $thumb = $media->thumbnail_path;
    Severity: Minor
    Found in app/Jobs/MediaPipeline/MediaDeletePipeline.php - About 1 hr to fix

      Method headerBlurhash has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function headerBlurhash()
          {
              return Cache::rememberForever(self::CACHE_KEY_BANNER_BLURHASH, function() {
                  if(str_ends_with(config_cache('app.banner_image'), 'headers/default.jpg')) {
                      return 'UzJR]l{wHZRjM}R%XRkCH?X9xaWEjZj]kAjt';
      Severity: Minor
      Found in app/Services/InstanceService.php - About 1 hr to fix

        Method reports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function reports(Request $request)
            {
                $filter = $request->input('filter') == 'closed' ? 'closed' : 'open';
                $page = $request->input('page') ?? 1;
        
        
        Severity: Minor
        Found in app/Http/Controllers/Admin/AdminReportController.php - About 1 hr to fix

          Method handleReportAction has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handleReportAction(Report $report, $action)
              {
                  $item = $report->reported();
                  $report->admin_seen = Carbon::now();
          
          
          Severity: Minor
          Found in app/Http/Controllers/Admin/AdminReportController.php - About 1 hr to fix

            Method getConfiguration has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getConfiguration(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 1 hr to fix

              Method avatarUrl has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function avatarUrl()
                  {
                      $url = Cache::remember('avatar:'.$this->id, 1209600, function () {
                          $avatar = $this->avatar;
              
              
              Severity: Minor
              Found in app/Profile.php - About 1 hr to fix

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

                    public function handle()
                    {
                        $action = select(
                            'What action do you want to perform?',
                            [
                Severity: Minor
                Found in app/Console/Commands/InstanceManager.php - About 1 hr to fix

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

                          if ($action == 'dismiss-all') {
                              AccountInterstitial::whereType('post.autospam')
                                  ->whereItemType('App\Status')
                                  ->whereNull('appeal_handled_at')
                                  ->whereUserId($appeal->user_id)
                  Severity: Major
                  Found in app/Http/Controllers/Admin/AdminReportController.php and 1 other location - About 1 hr to fix
                  app/Http/Controllers/Api/AdminApiController.php on lines 173..183

                  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 ($parent && ($parent->profile_id == $user->profile_id) || ($status->profile_id == $user->profile_id) || $user->is_admin) {
                                  Cache::forget('_api:statuses:recent_9:'.$status->profile_id);
                                  Cache::forget('profile:status_count:'.$status->profile_id);
                                  Cache::forget('profile:embed:'.$status->profile_id);
                                  StatusService::del($status->id, true);
                  Severity: Major
                  Found in app/Http/Controllers/StatusController.php and 1 other location - About 1 hr to fix
                  app/Http/Controllers/StatusController.php on lines 273..280

                  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($action == 'dismiss-all') {
                              AccountInterstitial::whereType('post.autospam')
                                  ->whereItemType('App\Status')
                                  ->whereNull('appeal_handled_at')
                                  ->whereUserId($appeal->user_id)
                  Severity: Major
                  Found in app/Http/Controllers/Api/AdminApiController.php and 1 other location - About 1 hr to fix
                  app/Http/Controllers/Admin/AdminReportController.php on lines 330..341

                  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

                          } elseif ($status->profile_id == $user->profile_id || $user->is_admin == true) {
                              Cache::forget('_api:statuses:recent_9:'.$status->profile_id);
                              Cache::forget('profile:status_count:'.$status->profile_id);
                              Cache::forget('profile:embed:'.$status->profile_id);
                              StatusService::del($status->id, true);
                  Severity: Major
                  Found in app/Http/Controllers/StatusController.php and 1 other location - About 1 hr to fix
                  app/Http/Controllers/StatusController.php on lines 265..272

                  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

                  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

                  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->caption) {
                                  $keywords = config('costar.keyword.block');
                                  foreach ($keywords as $kw) {
                  Severity: Major
                  Found in app/Http/Controllers/ComposeController.php and 2 other locations - About 1 hr to fix
                  app/Http/Controllers/Api/ApiV1Controller.php on lines 3330..3340
                  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

                  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->caption) {
                                  $keywords = config('costar.keyword.block');
                                  foreach ($keywords as $kw) {
                  Severity: Major
                  Found in app/Http/Controllers/ComposeController.php and 2 other locations - About 1 hr to fix
                  app/Http/Controllers/Api/ApiV1Controller.php on lines 3330..3340
                  app/Http/Controllers/ComposeController.php on lines 480..490

                  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

                  Function toBlob has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      canvas_proto.toBlob = function(callback, type /*, ...args*/) {
                            if (!type) {
                              type = "image/png";
                          } if (this.mozGetAsFile) {
                              callback(this.mozGetAsFile("canvas", type));
                  Severity: Minor
                  Found in resources/assets/js/polyfill.js - About 1 hr to fix

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

                        public function handleAnnounceActivity()
                        {
                            $actor = $this->actorFirstOrCreate($this->payload['actor']);
                            $activity = $this->payload['object'];
                    
                    
                    Severity: Minor
                    Found in app/Util/ActivityPub/Inbox.php - About 1 hr to fix

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

                          public static function generate(Media $media)
                          {
                              if(!in_array($media->mime, ['image/png', 'image/jpeg', 'video/mp4'])) {
                                  return self::DEFAULT_HASH;
                              }
                      Severity: Minor
                      Found in app/Util/Media/Blurhash.php - About 1 hr to fix

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

                            public static function mentionedUsernameExists($username)
                            {
                                $key = 'pf:services:autolink:userexists:' . hash('sha256', $username);
                        
                                return Cache::remember($key, 3600, function() use($username) {
                        Severity: Minor
                        Found in app/Services/AutolinkService.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language