pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Method handleUser has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function handleUser($user)
    {
        if(in_array($user->status, ['deleted', 'delete'])) {
            return;
        }
Severity: Major
Found in app/Observers/UserObserver.php - About 2 hrs to fix

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

        public function handle()
        {
            $this->info('Creating a new user...');
    
            $o = $this->options();
    Severity: Major
    Found in app/Console/Commands/UserCreate.php - About 2 hrs to fix

      Function handleNoteCreate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handleNoteCreate()
          {
              $activity = $this->payload['object'];
              $actor = $this->actorFirstOrCreate($this->payload['actor']);
              if(!$actor || $actor->domain == null) {
      Severity: Minor
      Found in app/Util/ActivityPub/Inbox.php - About 2 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 getMinMastodon has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getMinMastodon($id = false, $start = 0, $limit = 10)
          {
              $ids = self::getRankedMinId($id, $start, $limit);
      
              if (empty($ids)) {
      Severity: Minor
      Found in app/Services/NotificationService.php - About 2 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 handleImmediateAttributes has a Cognitive Complexity of 17 (exceeds 5 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 2 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 directoryInitialData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function directoryInitialData(Request $request)
          {
              $res = [];
      
              $res['countries'] = collect((new ISO3166)->all())->pluck('name');
      Severity: Minor
      Found in app/Http/Controllers/Admin/AdminDirectoryController.php - About 2 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 mediaUploadV2 has a Cognitive Complexity of 17 (exceeds 5 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: Minor
      Found in app/Http/Controllers/Api/ApiV2Controller.php - About 2 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 mediaUploadV2 has a Cognitive Complexity of 17 (exceeds 5 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: Minor
      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 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 handleUser has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function handleUser($user)
          {
              if(in_array($user->status, ['deleted', 'delete'])) {
                  return;
              }
      Severity: Minor
      Found in app/Observers/UserObserver.php - About 2 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 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handle()
          {
              if(!$this->confirm('Are you sure you want to run the fix status command?')) {
                  return;
              }
      Severity: Minor
      Found in app/Console/Commands/FixStatusCount.php - About 2 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

      File MediaStorageService.php has 260 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace App\Services;
      
      use App\Jobs\AvatarPipeline\AvatarStorageCleanup;
      Severity: Minor
      Found in app/Services/MediaStorageService.php - About 2 hrs to fix

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

            public function handle()
            {
                $status = $this->status;
                $profile = $status->profile;
        
        

          Method delete has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function delete(Request $request)
              {
                  $this->validate($request, [
                      'id' => 'required'
                  ]);
          Severity: Major
          Found in app/Http/Controllers/DirectMessageController.php - About 2 hrs to fix

            File api.php has 260 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            use Illuminate\Http\Request;
            use App\Http\Middleware\DeprecatedEndpoint;
            use App\Http\Controllers\Api\V1\TagsController;
            Severity: Minor
            Found in routes/api.php - About 2 hrs to fix

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

                          '@context' => [
                              'https://w3id.org/security/v1',
                              'https://www.w3.org/ns/activitystreams',
                              [
                                  'Hashtag'             => 'as:Hashtag',
              Severity: Major
              Found in app/Transformer/ActivityPub/Verb/CreateQuestion.php and 2 other locations - About 2 hrs to fix
              app/Transformer/ActivityPub/Verb/Question.php on lines 35..66
              app/Transformer/ActivityPub/Verb/UpdateNote.php on lines 57..88

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

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

                          '@context' => [
                              'https://w3id.org/security/v1',
                              'https://www.w3.org/ns/activitystreams',
                              [
                                  'Hashtag'             => 'as:Hashtag',
              Severity: Major
              Found in app/Transformer/ActivityPub/Verb/UpdateNote.php and 2 other locations - About 2 hrs to fix
              app/Transformer/ActivityPub/Verb/CreateQuestion.php on lines 18..49
              app/Transformer/ActivityPub/Verb/Question.php on lines 35..66

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

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

                          '@context' => [
                              'https://w3id.org/security/v1',
                              'https://www.w3.org/ns/activitystreams',
                              [
                                  'Hashtag'             => 'as:Hashtag',
              Severity: Major
              Found in app/Transformer/ActivityPub/Verb/Question.php and 2 other locations - About 2 hrs to fix
              app/Transformer/ActivityPub/Verb/CreateQuestion.php on lines 18..49
              app/Transformer/ActivityPub/Verb/UpdateNote.php on lines 57..88

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

              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 AdminInstanceController.php has 259 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace App\Http\Controllers\Admin;
              
              use DB, Cache;
              Severity: Minor
              Found in app/Http/Controllers/Admin/AdminInstanceController.php - About 2 hrs to fix

                Method regularMode has 55 lines of code (exceeds 25 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: Major
                Found in app/Console/Commands/MediaS3GarbageCollector.php - About 2 hrs to fix

                  File NotificationService.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace App\Services;
                  
                  use App\Jobs\InternalPipeline\NotificationEpochUpdatePipeline;
                  Severity: Minor
                  Found in app/Services/NotificationService.php - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language