SergiX44/XBackBone

View on GitHub

Showing 48 of 63 total issues

File MediaController.php has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Controllers;

use App\Database\Repositories\UserRepository;
Severity: Minor
Found in app/Controllers/MediaController.php - About 4 hrs to fix

    Function migrate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function migrate(): void
        {
            $this->db->getPdo()->exec(file_get_contents($this->schemaPath.DIRECTORY_SEPARATOR.'migrations.sql'));
    
            $files = glob($this->schemaPath.'/'.$this->db->getCurrentDriver().'/*.sql');
    Severity: Minor
    Found in app/Database/Migrator.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 runWithFileSort has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function runWithFileSort(int $page): MediaRepository
        {
            $this->storage->addPlugin(new ListWith());
    
            if ($this->isAdmin) {
    Severity: Minor
    Found in app/Database/Repositories/MediaRepository.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 runWithFileSort has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function runWithFileSort(int $page): MediaRepository
        {
            $this->storage->addPlugin(new ListWith());
    
            if ($this->isAdmin) {
    Severity: Major
    Found in app/Database/Repositories/MediaRepository.php - About 2 hrs to fix

      Function ldapLogin has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function ldapLogin(Request $request, string $username, string $password, $dbUser)
          {
              // Build LDAP connection
              $server = $this->ldapConnect();
              if (!$server) {
      Severity: Minor
      Found in app/Controllers/Auth/LoginController.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 show has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function show(
              Request $request,
              Response $response,
              string $userCode,
              string $mediaCode,
      Severity: Major
      Found in app/Controllers/MediaController.php - About 2 hrs to fix

        Method ldapLogin has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function ldapLogin(Request $request, string $username, string $password, $dbUser)
            {
                // Build LDAP connection
                $server = $this->ldapConnect();
                if (!$server) {
        Severity: Minor
        Found in app/Controllers/Auth/LoginController.php - About 1 hr to fix

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

              public function update(Request $request, Response $response, int $id): Response
              {
                  $user = make(UserRepository::class)->get($request, $id);
                  $user->max_disk_quota = -1;
          
          
          Severity: Minor
          Found in app/Controllers/UserController.php - About 1 hr to fix

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

                public function store(Request $request, Response $response): Response
                {
                    $maxUserQuota = -1;
                    $validator = $this->getUserCreateValidator($request)
                        ->callIf($this->getSetting('quota_enabled') === 'on', function ($session) use (&$maxUserQuota, &$request) {
            Severity: Minor
            Found in app/Controllers/UserController.php - About 1 hr to fix

              Function getString has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getString($key, $lang, $args): string
                  {
                      $redLang = strtolower(substr($lang, 0, 2));
              
                      if (array_key_exists($lang, $this->cache)) {
              Severity: Minor
              Found in app/Web/Lang.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 upgrade has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function upgrade(Response $response, Logger $logger, Session $session): Response
                  {
                      if (!extension_loaded('zip')) {
                          $session->alert(lang('zip_ext_not_loaded'), 'danger');
                          return redirect($response, route('system'));
              Severity: Minor
              Found in app/Controllers/UpgradeController.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 show has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function show(
                      Request $request,
                      Response $response,
                      string $userCode,
                      string $mediaCode,
              Severity: Minor
              Found in app/Controllers/MediaController.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 register has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function register(Request $request, Response $response): Response
                  {
                      if ($this->session->get('logged', false)) {
                          return redirect($response, route('home'));
                      }
              Severity: Minor
              Found in app/Controllers/Auth/RegisterController.php - About 1 hr to fix

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

                    public function login(Request $request, Response $response): Response
                    {
                        /** @var ValidationHelper $validator */
                        $validator = make(ValidationHelper::class);
                
                
                Severity: Minor
                Found in app/Controllers/Auth/LoginController.php - About 1 hr to fix

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

                      public function migrate(): void
                      {
                          $this->db->getPdo()->exec(file_get_contents($this->schemaPath.DIRECTORY_SEPARATOR.'migrations.sql'));
                  
                          $files = glob($this->schemaPath.'/'.$this->db->getCurrentDriver().'/*.sql');
                  Severity: Minor
                  Found in app/Database/Migrator.php - About 1 hr to fix

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

                        public function home(Request $request, Response $response, int $page = 0): Response
                        {
                            $page = max(0, --$page);
                    
                            switch (param($request, 'sort', 'time')) {
                    Severity: Minor
                    Found in app/Controllers/DashboardController.php - About 1 hr to fix

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

                          protected function streamMedia(
                              Request $request,
                              Response $response,
                              Filesystem $storage,
                              $media,
                      Severity: Minor
                      Found in app/Controllers/MediaController.php - About 1 hr to fix

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

                            public function ldapConnect()
                            {
                                if (!extension_loaded('ldap')) {
                                    $this->logger->error('The LDAP extension is not loaded.');
                                    return false;
                        Severity: Minor
                        Found in app/Controllers/Auth/AuthController.php - About 1 hr to fix

                          Method runWithDbSort has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function runWithDbSort(int $page): MediaRepository
                              {
                                  $params = [];
                                  if ($this->isAdmin) {
                                      [$queryMedia, $queryPages] = $this->buildAdminQueries();
                          Severity: Minor
                          Found in app/Database/Repositories/MediaRepository.php - About 1 hr to fix

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

                                protected function getLdapRdn(string $username, $server)
                                {
                                    //Dynamic LDAP User Binding
                                    if (@is_string($this->config['ldap']['search_filter'])) {
                                        //Replace ???? with username
                            Severity: Minor
                            Found in app/Controllers/Auth/AuthController.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language