AJenbo/agcms

View on GitHub

Showing 151 of 1,190 total issues

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

    public function addressSave(Request $request, int $id, string $checkId): Response
    {
        $invoice = app(OrmService::class)->getOne(Invoice::class, $id);
        if ($redirect = $this->checkStatus($id, $checkId, $invoice)) {
            return $redirect;
Severity: Minor
Found in application/inc/Http/Controllers/Payment.php - About 1 hr to fix

    Method inventory has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function inventory(Request $request): Response
        {
            app(DbService::class)->addLoadedTable('bind', 'kat', 'krav', 'maerke', 'sider');
            $response = $this->cachedResponse();
            if ($response->isNotModified($request)) {
    Severity: Minor
    Found in application/inc/Http/Controllers/Admin/SiteTreeController.php - About 1 hr to fix

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

          public function rss(Request $request): Response
          {
              $db = app(DbService::class);
      
              $db->addLoadedTable('bind', 'files', 'kat', 'maerke', 'sider');
      Severity: Minor
      Found in application/inc/Http/Controllers/Feed.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 __construct has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct(array $data = [])
          {
              $this->setItemData(strval($data['item_data'] ?? '[]'))
                  ->setHasShippingAddress(boolval($data['has_shipping_address'] ?? false))
                  ->setTimeStamp(intval($data['timestamp'] ?? time()))
      Severity: Minor
      Found in application/inc/Models/Invoice.php - About 1 hr to fix

        Function updateOrientation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function updateOrientation(move) {
            orientation += orientation < 10 ? move : -move;
            switch (orientation) {
                case 1:
                    rotate = 0;
        Severity: Minor
        Found in source/javascript/admin/image-edit.js - About 1 hr to fix

          Method terms has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function terms(Request $request, int $id, string $checkId): Response
              {
                  $invoice = app(OrmService::class)->getOne(Invoice::class, $id);
                  if ($redirect = $this->checkStatus($id, $checkId, $invoice)) {
                      return $redirect;
          Severity: Minor
          Found in application/inc/Http/Controllers/Payment.php - About 1 hr to fix

            Method folderRename has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function folderRename(Request $request): JsonResponse
                {
                    $path = $request->getRequestString('path') ?? '';
                    $name = $request->getRequestString('name') ?? '';
                    $name = $this->fileService->cleanFileName($name);
            Severity: Minor
            Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 1 hr to fix

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

              function purifyHTML(string $html): string
              {
                  $config = HTMLPurifier_Config::createDefault();
                  /** @var Application */
                  $app = app();
              Severity: Minor
              Found in application/inc/helpers.php - About 1 hr to fix

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

                    public function index(Request $request, ?int $id = null): Response
                    {
                        $selectedId = intval($request->cookies->get('activekat', -1));
                        $openCategories = explode('<', strval($request->cookies->get('openkat', '')));
                        $openCategories = array_map('intval', $openCategories);
                Severity: Minor
                Found in application/inc/Http/Controllers/Admin/PageController.php - About 1 hr to fix

                  Function send has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function send() {
                      status("Klargøre data.");
                      totals = [];
                      uploads = [];
                  
                  
                  Severity: Minor
                  Found in source/javascript/admin/upload.js - About 1 hr to fix

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

                        public function update(Request $request, int $id): JsonResponse
                        {
                            $user = $request->user();
                            if (!$user || (!$user->hasAccess(User::ADMINISTRATOR) && $user->getId() !== $id)) {
                                throw new InvalidInput(_('You do not have permission to edit users.'), Response::HTTP_FORBIDDEN);
                    Severity: Minor
                    Found in application/inc/Http/Controllers/Admin/UserController.php - About 1 hr to fix

                      Function listInsertRowCallback has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function listInsertRowCallback(data) {
                          if (!genericCallback(data)) {
                              return;
                          }
                      
                      
                      Severity: Minor
                      Found in source/javascript/admin/list.js - About 1 hr to fix

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

                            public function addToAddressBook(Invoice $invoice, ?string $clientIp): void
                            {
                                /** @var string[] */
                                $countries = Countries::getOrdered();
                                $conteact = app(OrmService::class)->getOneByQuery(
                        Severity: Minor
                        Found in application/inc/Services/InvoiceService.php - About 1 hr to fix

                          Function sendCart has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              "sendCart": function() {
                                  const cart = shoppingCart.getCart();
                                  cart.name = document.getElementById("name").value;
                                  cart.attn = document.getElementById("attn").value;
                                  cart.address = document.getElementById("address").value;
                          Severity: Minor
                          Found in source/javascript/shoppingCart.js - About 1 hr to fix

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

                                public function image(Request $request, int $id): Response
                                {
                                    $file = app(OrmService::class)->getOne(File::class, $id);
                                    if (!$file) {
                                        throw new InvalidInput(_('File not found.'), Response::HTTP_NOT_FOUND);
                            Severity: Minor
                            Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 1 hr to fix

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

                                  public static function mapFromDB(array $data): array
                                  {
                                      $columnSortings = explode('<', $data['sorts']);
                                      $columnSortings = array_map('intval', $columnSortings);
                                      $columnTypes = explode('<', $data['cells']);
                              Severity: Minor
                              Found in application/inc/Models/Table.php - About 1 hr to fix

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

                                    public function status(Request $request, int $id, string $checkId): Response
                                    {
                                        $invoice = app(OrmService::class)->getOne(Invoice::class, $id);
                                        if (!$invoice || $checkId !== $invoice->getCheckId()) {
                                            return redirect('/betaling/?id=' . $id . '&checkid=' . rawurlencode($checkId), Response::HTTP_SEE_OTHER);
                                Severity: Minor
                                Found in application/inc/Http/Controllers/Payment.php - About 1 hr to fix

                                  Function siteMap has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function siteMap(Request $request): Response
                                      {
                                          app(DbService::class)->addLoadedTable('bind', 'kat', 'sider', 'special', 'maerke', 'krav');
                                          $response = new Response('', Response::HTTP_OK, ['Content-Type' => 'text/xml;charset=utf-8']);
                                          $response = $this->cachedResponse($response);
                                  Severity: Minor
                                  Found in application/inc/Http/Controllers/Feed.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 getRows has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function getRows(?int $orderBy = null): array
                                      {
                                          $db = app(DbService::class);
                                  
                                          $dataRows = $db->fetchArray(
                                  Severity: Minor
                                  Found in application/inc/Models/Table.php - About 1 hr to fix

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

                                        public function getPages(string $order = 'navn', bool $reverseOrder = false): array
                                        {
                                            app(DbService::class)->addLoadedTable('bind');
                                    
                                            if (!in_array($order, ['navn', 'for', 'pris', 'varenr'], true)) {
                                    Severity: Minor
                                    Found in application/inc/Models/Category.php - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language