SergiX44/XBackBone

View on GitHub

Showing 51 of 66 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 24 (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 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 runWithFileSort has 74 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

      File app.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var app = {
          init: function () {
              Dropzone.options.uploadDropzone = {
                  paramName: 'upload',
                  maxFilesize: window.AppConfig.max_upload_size / Math.pow(1024, 2), // MB
      Severity: Minor
      Found in src/js/app.js - About 2 hrs to fix

        File MediaRepository.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace App\Database\Repositories;
        
        use App\Database\DB;
        Severity: Minor
        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 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 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 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 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 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 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
                              Severity
                              Category
                              Status
                              Source
                              Language