pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Method settingsHomeStore has 156 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function settingsHomeStore(Request $request)
    {
        $this->validate($request, [
            'name' => 'nullable|string',
            'short_description' => 'nullable',
Severity: Major
Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 6 hrs to fix

    Method statusFirstOrFetch has 155 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function statusFirstOrFetch($url, $replyTo = false)
        {
            $url = self::validateUrl($url);
            if ($url == false) {
                return;
    Severity: Major
    Found in app/Util/ActivityPub/Helpers.php - About 6 hrs to fix

      Method userAdminAction has 154 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function userAdminAction(Request $request)
          {
              abort_if(!$request->user() || !$request->user()->token(), 404);
      
              abort_unless($request->user()->is_admin == 1, 404);
      Severity: Major
      Found in app/Http/Controllers/Api/AdminApiController.php - About 6 hrs to fix

        File Installer.php has 423 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace App\Console\Commands;
        
        use Illuminate\Console\Command;
        Severity: Minor
        Found in app/Console/Commands/Installer.php - About 6 hrs to fix

          Method modAction has 153 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function modAction(Request $request)
              {
                  abort_unless(Auth::user()->is_admin, 400);
                  $this->validate($request, [
                      'action' => [
          Severity: Major
          Found in app/Http/Controllers/InternalApiController.php - About 6 hrs to fix

            Function settingsHomeStore has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
            Open

                public function settingsHomeStore(Request $request)
                {
                    $this->validate($request, [
                        'name' => 'nullable|string',
                        'short_description' => 'nullable',
            Severity: Minor
            Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 6 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

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

                        if($profile->user_id) {
                            DB::table('oauth_access_tokens')->whereUserId($user->id)->delete();
                            DB::table('oauth_auth_codes')->whereUserId($user->id)->delete();
                            $user->email = $user->id;
                            $user->password = '';
            Severity: Major
            Found in app/Http/Controllers/Api/AdminApiController.php and 1 other location - About 6 hrs to fix
            app/Http/Controllers/Admin/AdminReportController.php on lines 1012..1030

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

            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

                            if ($profile->user_id) {
                                DB::table('oauth_access_tokens')->whereUserId($user->id)->delete();
                                DB::table('oauth_auth_codes')->whereUserId($user->id)->delete();
                                $user->email = $user->id;
                                $user->password = '';
            Severity: Major
            Found in app/Http/Controllers/Admin/AdminReportController.php and 1 other location - About 6 hrs to fix
            app/Http/Controllers/Api/AdminApiController.php on lines 570..588

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

            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 store has 148 lines of code (exceeds 25 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: Major
            Found in app/Http/Controllers/ComposeController.php - About 5 hrs to fix

              Function handleDeleteActivity has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function handleDeleteActivity()
                  {
                      if(!isset(
                          $this->payload['actor'],
                          $this->payload['object']
              Severity: Minor
              Found in app/Util/ActivityPub/Inbox.php - About 5 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 StatusController.php has 397 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace App\Http\Controllers;
              
              use App\AccountInterstitial;
              Severity: Minor
              Found in app/Http/Controllers/StatusController.php - About 5 hrs to fix

                File InternalApiController.php has 396 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/InternalApiController.php - About 5 hrs to fix

                  Method resolveQuery has 137 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function resolveQuery()
                      {
                          $default = [
                              'accounts' => [],
                              'hashtags' => [],
                  Severity: Major
                  Found in app/Services/SearchApiV2Service.php - About 5 hrs to fix

                    Method homeTimelineApi has 134 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method publicTimelineApi has 132 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function publicTimelineApi(Request $request)
                          {
                              $this->validate($request,[
                                'page'        => 'nullable|integer|max:40',
                                'min_id'      => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
                      Severity: Major
                      Found in app/Http/Controllers/PublicApiController.php - About 5 hrs to fix

                        Function timelinePublic has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function timelinePublic(Request $request)
                            {
                                $this->validate($request, [
                                    'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
                                    'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
                        Severity: Minor
                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 5 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 get has 131 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function get($key)
                            {
                                $cacheKey = self::CACHE_KEY.$key;
                                $ttl = now()->addHours(12);
                                if (! config('instance.enable_cc')) {
                        Severity: Major
                        Found in app/Services/ConfigCacheService.php - About 5 hrs to fix

                          File AdminDirectoryController.php has 382 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          
                          namespace App\Http\Controllers\Admin;
                          
                          use App\Http\Controllers\PixelfedDirectoryController;
                          Severity: Minor
                          Found in app/Http/Controllers/Admin/AdminDirectoryController.php - About 5 hrs to fix

                            Profile has 39 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class Profile extends Model
                            {
                                use HasSnowflakePrimary, SoftDeletes;
                            
                                /**
                            Severity: Minor
                            Found in app/Profile.php - About 5 hrs to fix

                              Function handleFlagActivity has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function handleFlagActivity()
                                  {
                                      if(!isset(
                                          $this->payload['id'],
                                          $this->payload['type'],
                              Severity: Minor
                              Found in app/Util/ActivityPub/Inbox.php - About 5 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