pixelfed/pixelfed

View on GitHub

Showing 1,527 of 1,530 total issues

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

        $this->validate($request, [
            'file.*' => [
                'required_without:file',
                'mimetypes:' . config_cache('pixelfed.media_types'),
                'max:' . config_cache('pixelfed.max_photo_size'),
Severity: Major
Found in app/Http/Controllers/Api/ApiV2Controller.php and 1 other location - About 1 hr to fix
app/Http/Controllers/Api/ApiV1Controller.php on lines 1933..1948

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

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 2 locations. Consider refactoring.
Open

    public static function getMax($id = false, $start = 0, $limit = 10)
    {
        $ids = self::getRankedMaxId($id, $start, $limit);

        if (empty($ids)) {
Severity: Major
Found in app/Services/NotificationService.php and 1 other location - About 1 hr to fix
app/Services/NotificationService.php on lines 97..114

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

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 2 locations. Consider refactoring.
Open

            $data = Cache::remember('account:export:profile:statuses:ap:'.Auth::user()->profile->id, now()->addHours(1), function() {
                $profile = Auth::user()->profile->statuses;
                $fractal = new Fractal\Manager();
                $fractal->setSerializer(new ArraySerializer());
                $resource = new Fractal\Resource\Collection($profile, new StatusTransformer());
Severity: Major
Found in app/Http/Controllers/Settings/ExportSettings.php and 1 other location - About 1 hr to fix
app/Http/Controllers/Settings/ExportSettings.php on lines 128..134

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

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 2 locations. Consider refactoring.
Open

            $data = Cache::remember('account:export:profile:statuses:api:'.Auth::user()->profile->id, now()->addHours(1), function() {
                $profile = Auth::user()->profile->statuses;
                $fractal = new Fractal\Manager();
                $fractal->setSerializer(new ArraySerializer());
                $resource = new Fractal\Resource\Collection($profile, new StatusApiTransformer());
Severity: Major
Found in app/Http/Controllers/Settings/ExportSettings.php and 1 other location - About 1 hr to fix
app/Http/Controllers/Settings/ExportSettings.php on lines 119..125

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

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

        $this->validate($request, [
            'file.*' => [
                'required_without:file',
                'mimetypes:'.config_cache('pixelfed.media_types'),
                'max:'.config_cache('pixelfed.max_photo_size'),
Severity: Major
Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
app/Http/Controllers/Api/ApiV2Controller.php on lines 211..226

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

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 2 locations. Consider refactoring.
Open

    public static function getMin($id = false, $start = 0, $limit = 10)
    {
        $ids = self::getRankedMinId($id, $start, $limit);

        if (empty($ids)) {
Severity: Major
Found in app/Services/NotificationService.php and 1 other location - About 1 hr to fix
app/Services/NotificationService.php on lines 78..95

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

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 stringEncode has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function stringEncode (string) {
    var pos = 0
    var len = string.length
    var Arr = global.Uint8Array || Array // Use byte array when possible

Severity: Minor
Found in resources/assets/js/polyfill.js - About 1 hr to fix

    Method remoteAnnounceDeliver has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function remoteAnnounceDeliver()
        {
            if(config('app.env') !== 'production' || config_cache('federation.activitypub.enabled') == false) {
                return true;
            }
    Severity: Minor
    Found in app/Jobs/SharePipeline/SharePipeline.php - About 1 hr to fix

      Method blindKeyRotation has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function blindKeyRotation($headers, $profile, $payload)
          {
              $signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
              $date = is_array($headers['date']) ? $headers['date'][0] : $headers['date'];
              if(!$signature) {
      Severity: Minor
      Found in app/Jobs/InboxPipeline/InboxValidator.php - About 1 hr to fix

        Method blindKeyRotation has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function blindKeyRotation($headers, $payload)
            {
                $signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
                $date = is_array($headers['date']) ? $headers['date'][0] : $headers['date'];
                if(!$signature) {
        Severity: Minor
        Found in app/Jobs/InboxPipeline/InboxWorker.php - About 1 hr to fix

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

              public function handle()
              {
                  $story = $this->story;
                  $profile = $story->profile;
          
          
          Severity: Minor
          Found in app/Jobs/StoryPipeline/StoryFanout.php - About 1 hr to fix

            Method blindKeyRotation has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function blindKeyRotation($headers, $payload)
                {
                    $signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
                    $date = is_array($headers['date']) ? $headers['date'][0] : $headers['date'];
                    if(!$signature) {
            Severity: Minor
            Found in app/Jobs/InboxPipeline/DeleteWorker.php - About 1 hr to fix

              Method show has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function show(Request $request, $username, $id)
                  {
                      // redirect authed users to Metro 2.0
                      if ($request->user()) {
                          // unless they force static view
              Severity: Minor
              Found in app/Http/Controllers/StatusController.php - About 1 hr to fix

                Method directoryHandleServerSubmission has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function directoryHandleServerSubmission(Request $request)
                    {
                        $reqs = [];
                        $reqs['feature_config'] = [
                            'open_registration' => (bool) config_cache('pixelfed.open_registration'),
                Severity: Minor
                Found in app/Http/Controllers/Admin/AdminDirectoryController.php - About 1 hr to fix

                  Method trendingApi has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function trendingApi(Request $request)
                      {
                          abort_if(config('instance.discover.public') == false && ! $request->user(), 403);
                  
                          $this->validate($request, [
                  Severity: Minor
                  Found in app/Http/Controllers/DiscoverController.php - About 1 hr to fix

                    Method store has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function store(Request $request)
                        {
                            $this->validate($request, [
                                'item'    => 'required|integer|min:1',
                            ]);
                    Severity: Minor
                    Found in app/Http/Controllers/LikeController.php - About 1 hr to fix

                      Method statusComments has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function statusComments(Request $request, $username, int $postId)
                          {
                              $this->validate($request, [
                                  'min_id'    => 'nullable|integer|min:1',
                                  'max_id'    => 'nullable|integer|min:1|max:'.PHP_INT_MAX,
                      Severity: Minor
                      Found in app/Http/Controllers/PublicApiController.php - About 1 hr to fix

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

                            public function handle(): void
                            {
                                $this->info('       ____  _           ______         __  ');
                                $this->info('      / __ \(_)  _____  / / __/__  ____/ /  ');
                                $this->info('     / /_/ / / |/_/ _ \/ / /_/ _ \/ __  /   ');
                        Severity: Minor
                        Found in app/Console/Commands/AvatarStorageDeepClean.php - About 1 hr to fix

                          Method hugeMode has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function hugeMode($minId, $limit, $log)
                              {
                                  $cloudDisk = Storage::disk(config('filesystems.cloud'));
                                  $localDisk = Storage::disk('local');
                          
                          
                          Severity: Minor
                          Found in app/Console/Commands/MediaS3GarbageCollector.php - About 1 hr to fix

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

                                    if($collection['published_at'] == null || $collection['visibility'] != 'public') {
                                        abort_unless($user, 404);
                                        if($user->profile_id != $collection['pid']) {
                                            if(!$user->is_admin) {
                                                abort_if($collection['visibility'] != 'private', 404);
                            Severity: Major
                            Found in app/Http/Controllers/CollectionController.php and 1 other location - About 1 hr to fix
                            app/Http/Controllers/CollectionController.php on lines 187..195

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language