SergiX44/XBackBone

View on GitHub

Showing 59 of 66 total issues

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

          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

              Method handlePartialRequest has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function handlePartialRequest(
                      Response $response,
                      Stream $stream,
                      string $range,
                      string $disposition,
              Severity: Minor
              Found in app/Controllers/MediaController.php - About 1 hr to fix

                Function publishToggle has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    publishToggle: function () {
                        var id = $(this).data('id');
                        var $callerButton = $(this);
                        var isOutline = false;
                        if ($(this).data('published')) {
                Severity: Minor
                Found in src/js/app.js - About 1 hr to fix

                  Method saveMedia has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function saveMedia(Response $response, UploadedFileInterface $file, $user, $code)
                      {
                          if ($code === null) {
                              do {
                                  $code = humanRandomString();
                  Severity: Minor
                  Found in app/Controllers/UploadController.php - About 1 hr to fix

                    Method mime2font has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function mime2font($mime)
                        {
                            $classes = [
                                'image' => 'fa-file-image',
                                'audio' => 'fa-file-audio',
                    Severity: Minor
                    Found in app/helpers.php - About 1 hr to fix

                      Method recoverMail has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Function saveTag has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            saveTag: function () {
                                var tag = $(this).val();
                                var mediaId = $(this).data('id');
                                var $parent = $(this).parent();
                                if (tag === '') {
                        Severity: Minor
                        Found in src/js/app.js - About 1 hr to fix

                          Function login has a Cognitive Complexity of 10 (exceeds 5 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

                          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 getLdapRdn has a Cognitive Complexity of 10 (exceeds 5 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

                          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 createAppInstance has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function createAppInstance(Container $container)
                              {
                                  $config = $container->get('config');
                                  $loader = new FilesystemLoader(BASE_DIR.'resources/templates');
                          
                          
                          Severity: Minor
                          Found in app/Factories/ViewFactory.php - About 1 hr to fix

                            Method sendCreateNotification has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function sendCreateNotification($request, $resetToken = null)
                                {
                                    if ($resetToken === null && !empty(param($request, 'password'))) {
                                        $message = lang('mail.new_account_text_with_pw', [
                                            param($request, 'username'),
                            Severity: Minor
                            Found in app/Controllers/UserController.php - About 1 hr to fix

                              Method checkForUpdates has 27 lines of code (exceeds 25 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 1 hr to fix

                                Function addTag has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    addTag: function (e) {
                                        var $caller = $(this);
                                        var $newAddTag = $caller.clone()
                                            .click(app.addTag)
                                            .appendTo($caller.parent());
                                Severity: Minor
                                Found in src/js/app.js - About 1 hr to fix

                                  Method __construct has 26 lines of code (exceeds 25 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 1 hr to fix

                                    Method getString has 26 lines of code (exceeds 25 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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language