elabftw/elabftw

View on GitHub
src/models/Users.php

Summary

Maintainability
D
2 days
Test Coverage

File Users.php has 542 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * @author Nicolas CARPi <nico-git@deltablot.email>
 * @copyright 2012 Nicolas CARPi
Severity: Major
Found in src/models/Users.php - About 1 day to fix

    Users has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Users implements RestInterface
    {
        public bool $needValidation = false;
    
        public array $userData = array();
    Severity: Minor
    Found in src/models/Users.php - About 3 hrs to fix

      Method createOne has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function createOne(
              string $email,
              array $teams,
              string $firstname = '',
              string $lastname = '',
      Severity: Major
      Found in src/models/Users.php - About 3 hrs to fix

        Method readFromQuery has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function readFromQuery(
                string $query,
                int $teamId = 0,
                bool $includeArchived = false,
                bool $onlyAdmins = false,
        Severity: Minor
        Found in src/models/Users.php - About 1 hr to fix

          Method patch has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function patch(Action $action, array $params): array
              {
                  $this->canWriteOrExplode($action);
                  match ($action) {
                      Action::Add => (
          Severity: Minor
          Found in src/models/Users.php - About 1 hr to fix

            Method update has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function update(UserParams $params): bool
                {
                    if ($params->getTarget() === 'password') {
                        throw new ImproperActionException('Use action:updatepassword to update the password');
                    }
            Severity: Minor
            Found in src/models/Users.php - About 1 hr to fix

              Method createOne has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      string $email,
                      array $teams,
                      string $firstname = '',
                      string $lastname = '',
                      string $passwordHash = '',
              Severity: Major
              Found in src/models/Users.php - About 1 hr to fix

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

                    private function update(UserParams $params): bool
                    {
                        if ($params->getTarget() === 'password') {
                            throw new ImproperActionException('Use action:updatepassword to update the password');
                        }
                Severity: Minor
                Found in src/models/Users.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 createOne has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function createOne(
                        string $email,
                        array $teams,
                        string $firstname = '',
                        string $lastname = '',
                Severity: Minor
                Found in src/models/Users.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

                There are no issues that match your filters.

                Category
                Status