SergiX44/XBackBone

View on GitHub

Showing 59 of 66 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function getKDEScript(Request $request, Response $response, int $id): Response
    {
        $user = make(UserRepository::class)->get($request, $id, true);

        if (!$user->token) {
Severity: Major
Found in app/Controllers/ClientController.php and 1 other location - About 4 hrs to fix
app/Controllers/ClientController.php on lines 97..116

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 171.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function getBashScript(Request $request, Response $response, int $id): Response
    {
        $user = make(UserRepository::class)->get($request, $id, true);

        if (!$user->token) {
Severity: Major
Found in app/Controllers/ClientController.php and 1 other location - About 4 hrs to fix
app/Controllers/ClientController.php on lines 128..147

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 171.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                case 'azure':
                    $('#storage_account_name').prop('required', 'required').parent().parent().show();
                    $('#storage_account_key').prop('required', 'required').parent().parent().show();
                    $('#storage_container_name').prop('required', 'required').parent().parent().show();
                    break;
    Severity: Major
    Found in src/js/installer.js and 1 other location - About 4 hrs to fix
    src/js/installer.js on lines 50..54

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 116.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                case 'google-cloud':
                    $('#storage_project_id').prop('required', 'required').parent().parent().show();
                    $('#storage_key_path').prop('required', 'required').parent().parent().show();
                    $('#storage_bucket').prop('required', 'required').parent().parent().show();
                    break;
    Severity: Major
    Found in src/js/installer.js and 1 other location - About 4 hrs to fix
    src/js/installer.js on lines 55..59

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 116.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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 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

                  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

                  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
                      Severity
                      Category
                      Status
                      Source
                      Language