pixelfed/pixelfed

View on GitHub

Showing 1,555 of 1,558 total issues

File ApiV1Controller.php has 3183 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers\Api;

use App\Avatar;
Severity: Major
Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 wk to fix

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

        public function accountFollowersById(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 and 1 other location - About 4 days to fix
    app/Http/Controllers/Api/ApiV1Controller.php on lines 573..667

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

    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 function accountFollowingById(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 and 1 other location - About 4 days to fix
    app/Http/Controllers/Api/ApiV1Controller.php on lines 472..565

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

    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 function handleStoryReplyActivity()
        {
            if(!isset(
                $this->payload['actor'],
                $this->payload['id'],
    Severity: Major
    Found in app/Util/ActivityPub/Inbox.php and 1 other location - About 4 days to fix
    app/Util/ActivityPub/Inbox.php on lines 983..1103

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

    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 function handleStoryReactionActivity()
        {
            if(!isset(
                $this->payload['actor'],
                $this->payload['id'],
    Severity: Major
    Found in app/Util/ActivityPub/Inbox.php and 1 other location - About 4 days to fix
    app/Util/ActivityPub/Inbox.php on lines 1105..1226

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

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

    <?php
    
    namespace App\Http\Controllers\Admin;
    
    use App\AccountInterstitial;
    Severity: Major
    Found in app/Http/Controllers/Admin/AdminReportController.php - About 3 days to fix

      File Inbox.php has 1135 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace App\Util\ActivityPub;
      
      use Cache, DB, Log, Purify, Redis, Storage, Validator;
      Severity: Major
      Found in app/Util/ActivityPub/Inbox.php - About 2 days to fix

        File home.blade.php has 888 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        @extends('admin.partial.template-full')
        
        @section('section')
        <div class="title mb-4">
            <h3 class="font-weight-bold">Diagnostics</h3>
        Severity: Major
        Found in resources/views/admin/diagnostics/home.blade.php - About 2 days to fix

          File DirectMessageController.php has 796 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace App\Http\Controllers;
          
          use Auth, Cache;
          Severity: Major
          Found in app/Http/Controllers/DirectMessageController.php - About 1 day to fix

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

                    $nodes = $s->map(function ($s) use ($pid) {
                        $profile = AccountService::get($s->profile_id, true);
                        if (! $profile || ! isset($profile['id'])) {
                            return false;
                        }
            Severity: Major
            Found in app/Http/Controllers/Stories/StoryApiV1Controller.php and 1 other location - About 1 day to fix
            app/Http/Controllers/Stories/StoryApiV1Controller.php on lines 176..215

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

            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

                    $nodes = $s->map(function ($s) use ($pid) {
                        $profile = AccountService::get($s->profile_id, true);
                        if (! $profile || ! isset($profile['id'])) {
                            return false;
                        }
            Severity: Major
            Found in app/Http/Controllers/Stories/StoryApiV1Controller.php and 1 other location - About 1 day to fix
            app/Http/Controllers/Stories/StoryApiV1Controller.php on lines 64..103

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

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

            <?php
            
            namespace App\Http\Controllers\Admin;
            
            use App\Models\ConfigCache;
            Severity: Major
            Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 day to fix

              File ApiV1Dot1Controller.php has 766 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace App\Http\Controllers\Api;
              
              use Cache;
              Severity: Major
              Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php - About 1 day to fix

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

                        if(config('exp.cached_public_timeline') == false) {
                            if($min || $max) {
                                $dir = $min ? '>' : '<';
                                $id = $min ?? $max;
                                $timeline = Status::select(
                Severity: Major
                Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 day to fix
                app/Http/Controllers/PublicApiController.php on lines 541..634

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

                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(config('instance.timeline.network.cached') == false) {
                            if($min || $max) {
                                $dir = $min ? '>' : '<';
                                $id = $min ?? $max;
                                $timeline = Status::select(
                Severity: Major
                Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 day to fix
                app/Http/Controllers/PublicApiController.php on lines 247..364

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

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

                <?php
                
                namespace App\Http\Controllers\Api;
                
                use Illuminate\Http\Request;
                Severity: Major
                Found in app/Http/Controllers/Api/AdminApiController.php - About 1 day to fix

                  File Helpers.php has 718 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace App\Util\ActivityPub;
                  
                  use App\Instance;
                  Severity: Major
                  Found in app/Util/ActivityPub/Helpers.php - About 1 day to fix

                    File PublicApiController.php has 705 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    namespace App\Http\Controllers;
                    
                    use Illuminate\Http\Request;
                    Severity: Major
                    Found in app/Http/Controllers/PublicApiController.php - About 1 day to fix

                      File ComposeController.php has 688 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      
                      namespace App\Http\Controllers;
                      
                      use App\Collection;
                      Severity: Major
                      Found in app/Http/Controllers/ComposeController.php - About 1 day to fix

                        Function accountUpdateCredentials has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function accountUpdateCredentials(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 1 day 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