pixelfed/pixelfed

View on GitHub
app/Http/Controllers/Admin/AdminSettingsController.php

Summary

Maintainability
F
1 wk
Test Coverage

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

    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

      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

      Function settingsApiUpdateUsersType has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public function settingsApiUpdateUsersType($request)
          {
              $this->validate($request, [
                  'require_email_verification' => 'required',
                  'enforce_account_limit' => 'required',
      Severity: Minor
      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 3 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 settingsApiUpdateStorageType has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function settingsApiUpdateStorageType($request)
          {
              $this->validate($request, [
                  'primary_disk' => 'required|in:local,cloud',
                  'update_disk' => 'sometimes',
      Severity: Minor
      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 3 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 settingsApiUpdateStorageType has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function settingsApiUpdateStorageType($request)
          {
              $this->validate($request, [
                  'primary_disk' => 'required|in:local,cloud',
                  'update_disk' => 'sometimes',
      Severity: Major
      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 2 hrs to fix

        Method settingsApiUpdateUsersType has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function settingsApiUpdateUsersType($request)
            {
                $this->validate($request, [
                    'require_email_verification' => 'required',
                    'enforce_account_limit' => 'required',
        Severity: Major
        Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 2 hrs to fix

          Method settingsApiUpdatePlatformType has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function settingsApiUpdatePlatformType($request)
              {
                  $this->validate($request, [
                      'allow_app_registration' => 'required',
                      'app_registration_rate_limit_attempts' => 'required|integer|min:1',
          Severity: Major
          Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 2 hrs to fix

            Method settingsApiUpdateType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function settingsApiUpdateType(Request $request, $type)
                {
                    abort_unless(in_array($type, [
                        'posts',
                        'platform',
            Severity: Minor
            Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 hr to fix

              Method settingsApiUpdateHomeType has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function settingsApiUpdateHomeType($request)
                  {
                      $this->validate($request, [
                          'registration_status' => 'required|in:open,filtered,closed',
                          'cloud_storage' => 'required',
              Severity: Minor
              Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 hr to fix

                Method settings has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function settings(Request $request)
                    {
                        $cloud_storage = ConfigCacheService::get('pixelfed.cloud_storage');
                        $cloud_disk = config('filesystems.cloud');
                        $cloud_ready = ! empty(config('filesystems.disks.'.$cloud_disk.'.key')) && ! empty(config('filesystems.disks.'.$cloud_disk.'.secret'));
                Severity: Minor
                Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 hr to fix

                  Method settingsSystem has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function settingsSystem(Request $request)
                      {
                          $sys = [
                              'pixelfed' => config('pixelfed.version'),
                              'php' => phpversion(),
                  Severity: Minor
                  Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 hr to fix

                    Function settingsApiUpdateType has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function settingsApiUpdateType(Request $request, $type)
                        {
                            abort_unless(in_array($type, [
                                'posts',
                                'platform',
                    Severity: Minor
                    Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 hr 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 settingsApiUpdateMediaType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function settingsApiUpdateMediaType($request)
                        {
                            $this->validate($request, [
                                'image_quality' => 'required|integer|min:1|max:100',
                                'max_album_length' => 'required|integer|min:1|max:20',
                    Severity: Minor
                    Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 hr to fix

                      Function settingsApiAutofollowAdd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function settingsApiAutofollowAdd(Request $request)
                          {
                              $this->validate($request, [
                                  'username' => 'required|string',
                              ]);
                      Severity: Minor
                      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 55 mins 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 settingsApiUpdateHomeType has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function settingsApiUpdateHomeType($request)
                          {
                              $this->validate($request, [
                                  'registration_status' => 'required|in:open,filtered,closed',
                                  'cloud_storage' => 'required',
                      Severity: Minor
                      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 55 mins 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 settingsApiUpdatePlatformType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function settingsApiUpdatePlatformType($request)
                          {
                              $this->validate($request, [
                                  'allow_app_registration' => 'required',
                                  'app_registration_rate_limit_attempts' => 'required|integer|min:1',
                      Severity: Minor
                      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 35 mins 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

                      Avoid too many return statements within this method.
                      Open

                                      return $this->settingsApiUpdateMediaType($request);
                      Severity: Major
                      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $this->settingsApiUpdateStorageType($request);
                        Severity: Major
                        Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $this->settingsApiUpdateUsersType($request);
                          Severity: Major
                          Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return $this->settingsApiUpdateBrandingType($request);
                            Severity: Major
                            Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 30 mins to fix

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

                                  public function settingsApiUpdateBrandingType($request)
                                  {
                                      $this->validate($request, [
                                          'name' => 'required',
                                          'short_description' => 'required',
                              Severity: Major
                              Found in app/Http/Controllers/Admin/AdminSettingsController.php and 1 other location - About 3 hrs to fix
                              app/Http/Controllers/Admin/AdminSettingsController.php on lines 573..592

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

                              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 settingsApiUpdateLandingType($request)
                                  {
                                      $this->validate($request, [
                                          'current_admin' => 'required',
                                          'show_directory' => 'required',
                              Severity: Major
                              Found in app/Http/Controllers/Admin/AdminSettingsController.php and 1 other location - About 3 hrs to fix
                              app/Http/Controllers/Admin/AdminSettingsController.php on lines 629..648

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

                              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

                              There are no issues that match your filters.

                              Category
                              Status