SergiX44/XBackBone

View on GitHub

Showing 59 of 66 total issues

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

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

        /** @var ValidationHelper $validator */
Severity: Minor
Found in app/Controllers/ProfileController.php - About 1 hr to fix

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

        public function uploadEndpoint(Request $request, Response $response): Response
        {
            if ($this->config['maintenance']) {
                $this->json['message'] = 'Endpoint under maintenance.';
    
    
    Severity: Minor
    Found in app/Controllers/UploadController.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if (
                  UA::isBot($userAgent) &&
                  !(
                      // embed if enabled
                      (UA::embedsLinks($userAgent) &&
      Severity: Major
      Found in app/Controllers/MediaController.php - About 1 hr to fix

        Function runWithDbSort has a Cognitive Complexity of 9 (exceeds 5 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 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 checkForUpdates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function checkForUpdates(Request $request, Response $response): Response
            {
                $jsonResponse = [
                    'status' => 'OK',
                    'message' => lang('already_latest_version'),
        Severity: Minor
        Found in app/Controllers/UpgradeController.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 ldapConnect has a Cognitive Complexity of 8 (exceeds 5 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 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 dsnFromConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            function dsnFromConfig(array $config): string
            {
                $dsn = $config['db']['dsn'];
                if ($config['db']['connection'] === 'sqlite') {
                    if (getcwd() !== BASE_DIR) { // if in installer, change the working dir to the app dir
        Severity: Minor
        Found in app/helpers.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 __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct(string $name, $path = '')
            {
                if (session_status() === PHP_SESSION_NONE) {
                    if (!is_writable($path) && $path !== '') {
                        throw new Exception("The given path '{$path}' is not writable.");
        Severity: Minor
        Found in app/Web/Session.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 get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get(Request $request, $id, $authorize = false)
            {
                $user = $this->database->query('SELECT * FROM `users` WHERE `id` = ? LIMIT 1', $id)->fetch();
        
                if (!$user) {
        Severity: Minor
        Found in app/Database/Repositories/UserRepository.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

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

                        $('#db_password').prop('disabled', '').prop('required', 'required').parent().parent().show();
        Severity: Minor
        Found in src/js/installer.js and 1 other location - About 35 mins to fix
        src/js/installer.js on lines 20..20

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

        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

                        $('#db_user').prop('disabled', '').prop('required', 'required').parent().parent().show();
        Severity: Minor
        Found in src/js/installer.js and 1 other location - About 35 mins to fix
        src/js/installer.js on lines 21..21

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

        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

                    $message = lang('mail.new_account_text_with_reset', [
                        param($request, 'username'),
                        $this->config['app_name'],
                        $this->config['base_url'],
                        $this->config['base_url'],
        Severity: Minor
        Found in app/Controllers/UserController.php and 1 other location - About 30 mins to fix
        app/Controllers/Auth/RegisterController.php on lines 83..90

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

        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

                    ->message(lang('mail.activate_text', [
                        param($request, 'username'),
                        $this->config['app_name'],
                        $this->config['base_url'],
                        $this->config['base_url'],
        Severity: Minor
        Found in app/Controllers/Auth/RegisterController.php and 1 other location - About 30 mins to fix
        app/Controllers/UserController.php on lines 300..307

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

        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 reSyncQuotas has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function reSyncQuotas(Filesystem $filesystem)
            {
                $uploads = $this->db->query('SELECT `id`,`user_id`, `storage_path` FROM `uploads`')->fetchAll();
        
                $usersQuotas = [];
        Severity: Minor
        Found in app/Database/Migrator.php - About 25 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 deleteByToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function deleteByToken(
                Request $request,
                Response $response,
                string $userCode,
                string $mediaCode,
        Severity: Minor
        Found in app/Controllers/MediaController.php - About 25 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 buildAdminQueries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function buildAdminQueries()
            {
                $queryPages = 'SELECT COUNT(*) AS `count` FROM `uploads`';
                $queryMedia = 'SELECT `uploads`.*, `users`.`user_code`, `users`.`username` FROM `uploads` LEFT JOIN `users` ON `uploads`.`user_id` = `users`.`id`';
        
        
        Severity: Minor
        Found in app/Database/Repositories/MediaRepository.php - About 25 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 streamMedia has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function streamMedia(
                Request $request,
                Response $response,
                Filesystem $storage,
                $media,
        Severity: Minor
        Found in app/Controllers/MediaController.php - About 25 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 cleanDirectory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            function cleanDirectory($path, $all = false)
            {
                $directoryIterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
                $iteratorIterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::CHILD_FIRST);
                foreach ($iteratorIterator as $file) {
        Severity: Minor
        Found in app/helpers.php - About 25 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 __invoke has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __invoke(Throwable $exception, bool $displayErrorDetails): string
            {
                if ($exception instanceof UnderMaintenanceException) {
                    return view()->string('errors/maintenance.twig');
                }
        Severity: Minor
        Found in app/Exceptions/Handlers/Renderers/HtmlErrorRenderer.php - About 25 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

        Severity
        Category
        Status
        Source
        Language