pixelfed/pixelfed

View on GitHub

Showing 1,559 of 1,562 total issues

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

    public function transform(Status $status)
    {
        $mentions = $status->mentions->map(function ($mention) {
            $webfinger = $mention->emailUrl();
            $name = Str::startsWith($webfinger, '@') ?
Severity: Major
Found in app/Transformer/ActivityPub/Verb/UpdateNote.php - About 4 hrs to fix

    Method directoryInitialData has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Method networkTimelineApi has 111 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function networkTimelineApi(Request $request)
          {
              if(!$request->user()) {
                  return response('', 403);
              }
      Severity: Major
      Found in app/Http/Controllers/PublicApiController.php - About 4 hrs to fix

        Function handle has a Cognitive Complexity of 30 (exceeds 5 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: Minor
        Found in app/Jobs/FollowPipeline/FollowServiceWarmCache.php - About 4 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 store has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            public function store(Request $request)
            {
                $this->validate($request, [
                    'caption' => 'nullable|string|max:'.config_cache('pixelfed.max_caption_length', 500),
                    'media.*' => 'required',
        Severity: Minor
        Found in app/Http/Controllers/ComposeController.php - About 4 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 moderatePost has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            public function moderatePost(Request $request, $id)
            {
                abort_if(! $request->user() || ! $request->user()->token(), 403);
                abort_if($request->user()->is_admin != true, 403);
                abort_unless($request->user()->tokenCan('admin:write'), 403);
        Severity: Minor
        Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php - About 4 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 mediaUploadV2 has 110 lines of code (exceeds 25 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: Major
        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 4 hrs to fix

          File CuratedRegisterController.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace App\Http\Controllers;
          
          use Illuminate\Http\Request;
          Severity: Minor
          Found in app/Http/Controllers/CuratedRegisterController.php - About 4 hrs to fix

            File Status.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

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

              Method mediaUploadV2 has 109 lines of code (exceeds 25 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: Major
              Found in app/Http/Controllers/Api/ApiV2Controller.php - About 4 hrs to fix

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

                        $requests = function($audience) use ($client, $activity, $profile, $payload) {
                            foreach($audience as $url) {
                                $version = config('pixelfed.version');
                                $appUrl = config('app.url');
                                $headers = HttpSignature::sign($profile, $url, $activity, [
                Severity: Major
                Found in app/Jobs/StoryPipeline/StoryExpire.php and 3 other locations - About 4 hrs to fix
                app/Jobs/DeletePipeline/FanoutDeletePipeline.php on lines 64..82
                app/Jobs/StoryPipeline/StoryDelete.php on lines 109..127
                app/Jobs/StoryPipeline/StoryFanout.php on lines 80..98

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

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

                        $requests = function($audience) use ($client, $activity, $profile, $payload) {
                            foreach($audience as $url) {
                                $version = config('pixelfed.version');
                                $appUrl = config('app.url');
                                $headers = HttpSignature::sign($profile, $url, $activity, [
                Severity: Major
                Found in app/Jobs/StoryPipeline/StoryDelete.php and 3 other locations - About 4 hrs to fix
                app/Jobs/DeletePipeline/FanoutDeletePipeline.php on lines 64..82
                app/Jobs/StoryPipeline/StoryExpire.php on lines 126..144
                app/Jobs/StoryPipeline/StoryFanout.php on lines 80..98

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

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

                        $requests = function($audience) use ($client, $activity, $profile, $payload) {
                            foreach($audience as $url) {
                                $version = config('pixelfed.version');
                                $appUrl = config('app.url');
                                $headers = HttpSignature::sign($profile, $url, $activity, [
                Severity: Major
                Found in app/Jobs/DeletePipeline/FanoutDeletePipeline.php and 3 other locations - About 4 hrs to fix
                app/Jobs/StoryPipeline/StoryDelete.php on lines 109..127
                app/Jobs/StoryPipeline/StoryExpire.php on lines 126..144
                app/Jobs/StoryPipeline/StoryFanout.php on lines 80..98

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

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

                        $requests = function($audience) use ($client, $activity, $profile, $payload) {
                            foreach($audience as $url) {
                                $version = config('pixelfed.version');
                                $appUrl = config('app.url');
                                $headers = HttpSignature::sign($profile, $url, $activity, [
                Severity: Major
                Found in app/Jobs/StoryPipeline/StoryFanout.php and 3 other locations - About 4 hrs to fix
                app/Jobs/DeletePipeline/FanoutDeletePipeline.php on lines 64..82
                app/Jobs/StoryPipeline/StoryDelete.php on lines 109..127
                app/Jobs/StoryPipeline/StoryExpire.php on lines 126..144

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

                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

                File LiveStreamController.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace App\Http\Controllers;
                
                use Illuminate\Http\Request;
                Severity: Minor
                Found in app/Http/Controllers/LiveStreamController.php - About 4 hrs to fix

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

                      public function handle()
                      {
                          $profile = null;
                          $headers = $this->headers;
                          $payload = json_decode($this->payload, true, 8);
                  Severity: Minor
                  Found in app/Jobs/InboxPipeline/DeleteWorker.php - About 4 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 statusFavouritedBy has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function statusFavouritedBy(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 4 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 handle has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handle()
                      {
                          if(!config('import.instagram.enabled')) {
                              return;
                          }
                  Severity: Minor
                  Found in app/Console/Commands/TransformImports.php - About 4 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

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

                      public static function hiddenFollowers($id)
                      {
                          $account = self::get($id, true);
                          if(!$account || !isset($account['local']) || $account['local'] == false) {
                              return false;
                  Severity: Major
                  Found in app/Services/AccountService.php and 1 other location - About 4 hrs to fix
                  app/Services/AccountService.php on lines 206..224

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

                  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 hiddenFollowing($id)
                      {
                          $account = self::get($id, true);
                          if(!$account || !isset($account['local']) || $account['local'] == false) {
                              return false;
                  Severity: Major
                  Found in app/Services/AccountService.php and 1 other location - About 4 hrs to fix
                  app/Services/AccountService.php on lines 186..204

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

                  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