EscolaLMS/Auth

View on GitHub

Showing 24 of 31 total issues

UserService has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class UserService implements UserServiceContract
{
    private UserRepositoryContract $userRepository;

    /**
Severity: Minor
Found in src/Services/UserService.php - About 2 hrs to fix

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

        public function run()
        {
            $admin   = Role::findOrCreate(UserRole::ADMIN, 'api');
            $tutor   = Role::findOrCreate(UserRole::TUTOR, 'api');
            $student =  Role::findOrCreate(UserRole::STUDENT, 'api');
    Severity: Major
    Found in database/seeders/AuthPermissionSeeder.php - About 2 hrs to fix

      Method instantiateFromRequest has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function instantiateFromRequest(Request $request): self
          {
              $criteria = new Collection();
      
              if ($request->get('search')) {
      Severity: Minor
      Found in src/Dtos/UserFilterCriteriaDto.php - About 1 hr to fix

        Function patchUsingDto has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function patchUsingDto(UserUpdateDto $dto, UserUpdateKeysDto $keysDto, int $id): User
            {
                $data = $dto->toArray();
        
                $user = $this->userRepository->update($data, $id);
        Severity: Minor
        Found in src/Services/UserService.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

        Function putUsingDto has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function putUsingDto(UserUpdateDto $dto, int $id): User
            {
                $data = $dto->toArray();
        
                $user = $this->userRepository->update($data, $id);
        Severity: Minor
        Found in src/Services/UserService.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 __construct has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function __construct(bool $firstName = false, bool $lastName = false, bool $age = false, bool $gender = false, bool $country = false, bool $city = false, bool $street = false, bool $postcode = false, bool $email = false, bool $roles = false, bool $password = false)
        Severity: Major
        Found in src/Dtos/Admin/UserUpdateKeysDto.php - About 1 hr to fix

          Function instantiateFromRequest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function instantiateFromRequest(Request $request): self
              {
                  $criteria = new Collection();
          
                  if ($request->get('search')) {
          Severity: Minor
          Found in src/Dtos/UserFilterCriteriaDto.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 toArray has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function toArray($request)
              {
                  $fields = array_filter([
                      'id' => $this->id,
                      'name' => $this->name,
          Severity: Minor
          Found in src/Http/Resources/UserResource.php - About 1 hr to fix

            Method getReturnUrl has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getReturnUrl(string $provider, ?string $returnUrl, ?string $state): string
                {
                    $socialUser = Socialite::driver($provider)->stateless()->user();
                    $socialAccount = $this->socialAccountRepository->findByProviderAndProviderId($provider, $socialUser->getId());
            
            
            Severity: Minor
            Found in src/Services/SocialAccountService.php - About 1 hr to fix

              Method rules has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function rules()
                  {
                      $rules = [
                          'first_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
                          'last_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
              Severity: Minor
              Found in src/Http/Requests/Admin/UserCreateRequest.php - About 1 hr to fix

                Method rules has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function rules()
                    {
                        $rules =  [
                            'first_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
                            'last_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
                Severity: Minor
                Found in src/Http/Requests/RegisterRequest.php - About 1 hr to fix

                  Method rules has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function rules()
                      {
                          $rules = [
                              'first_name' => [$this->requiredIfPut(), 'string', 'max:255', new NoHtmlTags()],
                              'last_name' => [$this->requiredIfPut(), 'string', 'max:255', new NoHtmlTags()],
                  Severity: Minor
                  Found in src/Http/Requests/Admin/UserUpdateRequest.php - About 1 hr to fix

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

                        public function register(RegisterRequest $request): JsonResponse
                        {
                            $mustBeEnabledByAdmin = Config::get(
                                EscolaLmsAuthServiceProvider::CONFIG_KEY . '.account_must_be_enabled_by_admin', SettingStatusEnum::DISABLED
                            );
                    Severity: Minor
                    Found in src/Http/Controllers/RegisterApiController.php - About 1 hr to fix

                      Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function __construct(bool $firstName = false, bool $lastName = false, bool $age = false, bool $gender = false, bool $country = false, bool $city = false, bool $street = false, bool $postcode = false)
                      Severity: Major
                      Found in src/Dtos/UserUpdateKeysDto.php - About 1 hr to fix

                        Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                string $firstName,
                                string $lastName,
                                bool $isActive,
                                array $roles,
                                ?string $email = null,
                        Severity: Major
                        Found in src/Dtos/UserSaveDto.php - About 1 hr to fix

                          Method searchAndPaginate has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  CriteriaDto $criteriaDto,
                                  ?array $columns = [],
                                  ?array $with = [],
                                  ?array $appends = [],
                                  ?int $perPage = null,
                          Severity: Major
                          Found in src/Services/Contracts/UserServiceContract.php - About 50 mins to fix

                            Method searchAndPaginate has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    CriteriaDto $criteriaDto,
                                    ?array $columns = [],
                                    ?array $with = [],
                                    ?array $appends = [],
                                    ?int $perPage = null,
                            Severity: Major
                            Found in src/Services/UserService.php - About 50 mins to fix

                              Function askUserPassword has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function askUserPassword(bool $required = false)
                                  {
                                      $default = $required ? Str::random() : '';
                                      while (1) {
                                          $password = $this->ask('Password', $default);
                              Severity: Minor
                              Found in src/Console/Commands/CreateAdminCommand.php - About 45 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 instantiateFromRequest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public static function instantiateFromRequest(Request $request, bool $tree = false): self
                                  {
                                      $criteria = new Collection();
                              
                                      if (
                              Severity: Minor
                              Found in src/Dtos/UserGroupFilterCriteriaDto.php - About 45 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

                              Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      AuthServiceContract $authService,
                                      UserServiceContract $userService,
                                      SocialAccountRepositoryContract $socialAccountRepository,
                                      UserRepositoryContract $userRepository,
                                      PreUserRepositoryContract $preUserRepository
                              Severity: Minor
                              Found in src/Services/SocialAccountService.php - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language