visavi/rotor

View on GitHub
app/Http/Controllers/User/UserController.php

Summary

Maintainability
F
4 days
Test Coverage

File UserController.php has 615 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace App\Http\Controllers\User;
Severity: Major
Found in app/Http/Controllers/User/UserController.php - About 1 day to fix

    Method register has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function register(Request $request, Validator $validator)
        {
            if (getUser()) {
                abort(403, __('users.already_registered'));
            }
    Severity: Major
    Found in app/Http/Controllers/User/UserController.php - About 4 hrs to fix

      Function register has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          public function register(Request $request, Validator $validator)
          {
              if (getUser()) {
                  abort(403, __('users.already_registered'));
              }
      Severity: Minor
      Found in app/Http/Controllers/User/UserController.php - About 4 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 login has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function login(Request $request, Validator $validator, Flood $flood)
          {
              if (getUser()) {
                  setFlash('danger', __('main.already_authorized'));
      
      
      Severity: Minor
      Found in app/Http/Controllers/User/UserController.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

      Method profile has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function profile(Request $request, Validator $validator)
          {
              if (! $user = getUser()) {
                  abort(403, __('main.not_authorized'));
              }
      Severity: Major
      Found in app/Http/Controllers/User/UserController.php - About 2 hrs to fix

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

            public function key(Request $request, Validator $validator)
            {
                /* @var User $user */
                if (! $user = getUser()) {
                    abort(403, __('main.not_authorized'));
        Severity: Major
        Found in app/Http/Controllers/User/UserController.php - About 2 hrs to fix

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

              public function changeMail(Request $request, Validator $validator): RedirectResponse
              {
                  if (! $user = getUser()) {
                      abort(403, __('main.not_authorized'));
                  }
          Severity: Minor
          Found in app/Http/Controllers/User/UserController.php - About 1 hr to fix

            Method login has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function login(Request $request, Validator $validator, Flood $flood)
                {
                    if (getUser()) {
                        setFlash('danger', __('main.already_authorized'));
            
            
            Severity: Minor
            Found in app/Http/Controllers/User/UserController.php - About 1 hr to fix

              Method editPassword has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function editPassword(Request $request, Validator $validator): RedirectResponse
                  {
                      if (! $user = getUser()) {
                          abort(403, __('main.not_authorized'));
                      }
              Severity: Minor
              Found in app/Http/Controllers/User/UserController.php - About 1 hr to fix

                Method setting has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function setting(Request $request, Validator $validator)
                    {
                        if (! $user = getUser()) {
                            abort(403, __('main.not_authorized'));
                        }
                Severity: Minor
                Found in app/Http/Controllers/User/UserController.php - About 1 hr to fix

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

                      public function key(Request $request, Validator $validator)
                      {
                          /* @var User $user */
                          if (! $user = getUser()) {
                              abort(403, __('main.not_authorized'));
                  Severity: Minor
                  Found in app/Http/Controllers/User/UserController.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 checkLogin has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function checkLogin(Request $request, Validator $validator): JsonResponse
                      {
                          $login = (string) $request->input('login');
                  
                          $validator
                  Severity: Minor
                  Found in app/Http/Controllers/User/UserController.php - About 1 hr to fix

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

                        public function profile(Request $request, Validator $validator)
                        {
                            if (! $user = getUser()) {
                                abort(403, __('main.not_authorized'));
                            }
                    Severity: Minor
                    Found in app/Http/Controllers/User/UserController.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 apikey has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function apikey(Request $request): RedirectResponse
                        {
                            if (! $user = getUser()) {
                                abort(403, __('main.not_authorized'));
                            }
                    Severity: Minor
                    Found in app/Http/Controllers/User/UserController.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 view('users/login', compact('cookieLogin', 'isFlood'));
                    Severity: Major
                    Found in app/Http/Controllers/User/UserController.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status