pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

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

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

    protected function regularMode($minId, $limit, $log)
    {
        $gc = Media::whereRemoteMedia(false)
            ->whereNotNull(['status_id', 'cdn_url', 'replicated_at'])
            ->whereNot('version', '4')
Severity: Minor
Found in app/Console/Commands/MediaS3GarbageCollector.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 handleImageTransform has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handleImageTransform(Media $media, $thumbnail = false)
    {
        $path = $media->media_path;
        $file = storage_path('app/'.$path);
        if (!in_array($media->mime, $this->acceptedMimes)) {
Severity: Major
Found in app/Util/Media/Image.php - About 3 hrs to fix

    Method inAppRegistration has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function inAppRegistration(Request $request)
        {
            abort_if($request->user(), 404);
            abort_unless((bool) config_cache('pixelfed.open_registration'), 404);
            abort_unless((bool) config_cache('pixelfed.allow_app_registration'), 404);
    Severity: Major
    Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php - About 3 hrs to fix

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

      @extends('admin.partial.template-full')
      
      @section('section')
      <div class="title">
          <h3 class="font-weight-bold d-inline-block">Profiles</h3>
      Severity: Minor
      Found in resources/views/admin/profiles/home.blade.php - About 3 hrs to fix

        File Profile.php has 315 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

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

          File ProfileController.php has 314 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Method create has 88 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function create(Request $request)
                {
                    $this->validate($request, [
                        'to_id' => 'required',
                        'message' => 'required|string|min:1|max:500',
            Severity: Major
            Found in app/Http/Controllers/DirectMessageController.php - About 3 hrs to fix

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

                      $res['feature_config'] = [
                          'media_types' => Str::of(config_cache('pixelfed.media_types'))->explode(','),
                          'image_quality' => config_cache('pixelfed.image_quality'),
                          'optimize_image' => (bool) config_cache('pixelfed.optimize_image'),
                          'max_photo_size' => config_cache('pixelfed.max_photo_size'),
              Severity: Major
              Found in app/Http/Controllers/Admin/AdminDirectoryController.php and 1 other location - About 3 hrs to fix
              app/Http/Controllers/PixelfedDirectoryController.php on lines 102..113

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

              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['feature_config'] = [
                          'media_types' => Str::of(config_cache('pixelfed.media_types'))->explode(','),
                          'image_quality' => config_cache('pixelfed.image_quality'),
                          'optimize_image' => (bool) config_cache('pixelfed.optimize_image'),
                          'max_photo_size' => config_cache('pixelfed.max_photo_size'),
              Severity: Major
              Found in app/Http/Controllers/PixelfedDirectoryController.php and 1 other location - About 3 hrs to fix
              app/Http/Controllers/Admin/AdminDirectoryController.php on lines 74..85

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

              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 handleUndoActivity has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function handleUndoActivity()
                  {
                      $actor = $this->payload['actor'];
                      $profile = self::actorFirstOrCreate($actor);
                      $obj = $this->payload['object'];
              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 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

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

                               return Status::select(
                                        'id',
                                        'uri',
                                        'caption',
                                        'rendered',
                Severity: Major
                Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 3 hrs to fix
                app/Http/Controllers/PublicApiController.php on lines 465..507

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

                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

                            return Status::select(
                                        'id',
                                        'uri',
                                        'caption',
                                        'rendered',
                Severity: Major
                Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 3 hrs to fix
                app/Http/Controllers/PublicApiController.php on lines 415..458

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

                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

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

                    public function handle()
                    {
                        if(config('filesystems.default') !== 'local') {
                            $this->error('Invalid default filesystem, set FILESYSTEM_DRIVER=local to proceed');
                            return Command::SUCCESS;
                Severity: Major
                Found in app/Console/Commands/FixMediaDriver.php - About 3 hrs to fix

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

                      public function handle()
                      {
                          $user = $this->user;
                          $profile = $user->profile;
                          $id = $user->profile_id;
                  Severity: Major
                  Found in app/Jobs/DeletePipeline/DeleteAccountPipeline.php - About 3 hrs to fix

                    Method storeStatus has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function storeStatus($url, $profile, $activity)
                        {
                            $originalUrl = $url;
                            $id = isset($activity['id']) ? self::pluckval($activity['id']) : self::pluckval($activity['url']);
                            $url = isset($activity['url']) && is_string($activity['url']) ? self::pluckval($activity['url']) : self::pluckval($id);
                    Severity: Major
                    Found in app/Util/ActivityPub/Helpers.php - About 3 hrs to fix

                      Method spam has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function spam(Request $request)
                          {
                              $this->validate($request, [
                                  'tab' => 'sometimes|in:home,not-spam,spam,settings,custom,exemptions',
                              ]);
                      Severity: Major
                      Found in app/Http/Controllers/Admin/AdminReportController.php - About 3 hrs to fix

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

                            public function handle()
                            {
                                if(!$this->confirm('Are you sure you want to run the fix status command?')) {
                                    return;
                                }
                        Severity: Major
                        Found in app/Console/Commands/FixStatusCount.php - About 3 hrs to fix

                          Method handleFlagActivity has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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