pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

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

        if(filter_var($msg, FILTER_VALIDATE_URL)) {
            if(Helpers::validateUrl($msg)) {
                $dm->type = 'link';
                $dm->meta = [
                    'domain' => parse_url($msg, PHP_URL_HOST),
Severity: Major
Found in app/Http/Controllers/DirectMessageController.php and 1 other location - About 1 hr to fix
app/Util/ActivityPub/Inbox.php on lines 489..499

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

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

        if(filter_var($msgText, FILTER_VALIDATE_URL)) {
            if(Helpers::validateUrl($msgText)) {
                $dm->type = 'link';
                $dm->meta = [
                    'domain' => parse_url($msgText, PHP_URL_HOST),
Severity: Major
Found in app/Util/ActivityPub/Inbox.php and 1 other location - About 1 hr to fix
app/Http/Controllers/DirectMessageController.php on lines 359..369

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

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

    public static function getId($userId, $year, $month, $day)
    {
        if($userId > 999999) {
            return;
        }
Severity: Minor
Found in app/Services/ImportService.php - About 1 hr to fix

    Method followRequestHandle has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function followRequestHandle(Request $request)
        {
            $this->validate($request, [
                'action' => 'required|string|max:10',
                'id' => 'required|integer|min:1'
    Severity: Minor
    Found in app/Http/Controllers/AccountController.php - About 1 hr to fix

      Method resendConfirmationProcess has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function resendConfirmationProcess(Request $request)
          {
              $rules = [
                  'email' => [
                      'required',
      Severity: Minor
      Found in app/Http/Controllers/CuratedRegisterController.php - About 1 hr to fix

        Method remotePostLookup has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function remotePostLookup()
            {
                $tag = $this->term;
                $hash = hash('sha256', $tag);
                $local = Helpers::validateLocalUrl($tag);
        Severity: Minor
        Found in app/Http/Controllers/SearchController.php - About 1 hr to fix

          Method updateUrls has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function updateUrls()
              {
                  $this->info('Updating urls...');
                  $oldDomain = trim($this->argument('oldDomain'));
                  $newDomain = trim($this->argument('newDomain'));
          Severity: Minor
          Found in app/Console/Commands/MediaCloudUrlRewrite.php - About 1 hr to fix

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                    $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);
                        }
                        $admin = User::whereIsAdmin(true)->first();
            Severity: Major
            Found in app/Http/Controllers/Api/ApiV2Controller.php and 2 other locations - About 1 hr to fix
            app/Http/Controllers/Api/ApiV1Controller.php on lines 1600..1609
            app/Services/LandingService.php on lines 25..34

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

            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

                    $posts = $forYou->take(50)->map(function ($post) {
                        return StatusService::getMastodon($post);
                    })
                        ->filter(function ($post) use ($filters) {
                            return $post &&
            Severity: Major
            Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 hr to fix
            app/Http/Controllers/InternalApiController.php on lines 76..86

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

            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

                    $contactAccount = Cache::remember('api:v1:instance-data:contact', 604800, function () {
                        if (config_cache('instance.admin.pid')) {
                            return AccountService::getMastodon(config_cache('instance.admin.pid'), true);
                        }
                        $admin = User::whereIsAdmin(true)->first();
            Severity: Major
            Found in app/Services/LandingService.php and 2 other locations - About 1 hr to fix
            app/Http/Controllers/Api/ApiV1Controller.php on lines 1600..1609
            app/Http/Controllers/Api/ApiV2Controller.php on lines 51..59

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

            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

                    $posts = $forYou->take(50)->map(function($post) {
                        return StatusService::get($post);
                    })
                    ->filter(function($post) use($filters) {
                        return $post &&
            Severity: Major
            Found in app/Http/Controllers/InternalApiController.php and 1 other location - About 1 hr to fix
            app/Http/Controllers/Api/ApiV1Controller.php on lines 3928..3938

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

            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

                        $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);
                            }
                            $admin = User::whereIsAdmin(true)->first();
            Severity: Major
            Found in app/Http/Controllers/Api/ApiV1Controller.php and 2 other locations - About 1 hr to fix
            app/Http/Controllers/Api/ApiV2Controller.php on lines 51..59
            app/Services/LandingService.php on lines 25..34

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

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

                public function handle(): void
                {
                    $payload = $this->payload;
            
                    if(empty($payload) || !isset($payload['actor'])) {
            Severity: Minor
            Found in app/Jobs/ProfilePipeline/HandleUpdateActivity.php - About 1 hr to fix

              Method handleImmediateAttributes has 41 lines of code (exceeds 25 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 1 hr to fix

                Method unblock has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Method unmute has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Method storeId has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function storeId(Request $request)
                        {
                            abort_if(!$request->user(), 403);
                    
                            $this->validate($request, [
                    Severity: Minor
                    Found in app/Http/Controllers/CollectionController.php - About 1 hr to fix

                      Method add has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function add(Request $request)
                          {
                              abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                      
                              $this->validate($request, [
                      Severity: Minor
                      Found in app/Http/Controllers/Stories/StoryApiV1Controller.php - About 1 hr to fix

                        Method myMemories has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function myMemories(Request $request)
                            {
                                abort_if(! $request->user(), 404);
                                $pid = $request->user()->profile_id;
                                abort_if(! $this->config()['memories']['enabled'], 404);
                        Severity: Minor
                        Found in app/Http/Controllers/DiscoverController.php - About 1 hr to fix

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

                              public function handle()
                              {
                                  if(Schema::hasTable('instance_actors') == false) {
                                      $this->line(' ');
                                      $this->error('Missing instance_actors table.');
                          Severity: Minor
                          Found in app/Console/Commands/GenerateInstanceActor.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language