pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

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

          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

                Method createConfiguration has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function createConfiguration($request)
                    {
                        abort_if(file_exists(base_path('.env')), 404);
                        $source = base_path('.env.example');
                        $target = base_path('.env');
                Severity: Major
                Found in app/Http/Controllers/InstallController.php - About 2 hrs to fix

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

                      public function handle()
                      {
                  
                          $this->info('       ____  _           ______         __  ');
                          $this->info('      / __ \(_)  _____  / / __/__  ____/ /  ');
                  Severity: Major
                  Found in app/Console/Commands/FixHashtags.php - About 2 hrs to fix

                    Method apiV1Add has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function apiV1Add(Request $request)
                        {
                            abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                    
                            $this->validate($request, [
                    Severity: Major
                    Found in app/Http/Controllers/StoryComposeController.php - About 2 hrs to fix

                      Method statusContext has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function statusContext(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 2 hrs to fix

                        Function timeAhead has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                                timeAhead: (function(ts, short = true) {
                                    let date = Date.parse(ts);
                                    let diff = date - Date.parse(new Date());
                                    let seconds = Math.floor((diff) / 1000);
                                    let interval = Math.floor(seconds / 63072000);
                        Severity: Minor
                        Found in resources/assets/js/app.js - 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 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function handle()
                            {
                                $media = $this->media;
                                $path = $media->media_path;
                                $thumb = $media->thumbnail_path;
                        Severity: Minor
                        Found in app/Jobs/MediaPipeline/MediaDeletePipeline.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 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function handle(): void
                            {
                                $spamExists = Storage::exists(AutospamService::MODEL_SPAM_PATH);
                                if($spamExists) {
                                    $spam = json_decode(Storage::get(AutospamService::MODEL_SPAM_PATH), true);
                        Severity: Minor
                        Found in app/Jobs/AutospamPipeline/AutospamUpdateCachedDataPipeline.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 statusContext has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function statusContext(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 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 browse has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function browse(Request $request)
                            {
                                $this->validate($request, [
                                    'a' => 'nullable|string|in:inbox,sent,filtered',
                                    'page' => 'nullable|integer|min:1|max:99'
                        Severity: Minor
                        Found in app/Http/Controllers/DirectMessageController.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 networkTimelineApi has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function networkTimelineApi(Request $request)
                            {
                                if(!$request->user()) {
                                    return response('', 403);
                                }
                        Severity: Minor
                        Found in app/Http/Controllers/PublicApiController.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

                        Severity
                        Category
                        Status
                        Source
                        Language