AJenbo/agcms

View on GitHub

Showing 151 of 1,190 total issues

Function save has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function save(id = null, type = null) {
    if (type === "cancel" && !confirm("Are you sure you want to cancel this Invoice?")) {
        return false;
    }

Severity: Major
Found in source/javascript/admin/invoice.js - About 2 hrs to fix

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

        public static function mapFromDB(array $data): array
        {
            $itemQuantities = explode('<', $data['quantities']);
            $itemQuantities = array_map('intval', $itemQuantities);
            $itemValue = explode('<', $data['values']);
    Severity: Major
    Found in application/inc/Models/Invoice.php - About 2 hrs to fix

      File has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class File extends AbstractEntity
      {
          /** Table name in database. */
          public const TABLE_NAME = 'files';
      
      
      Severity: Minor
      Found in application/inc/Models/File.php - About 2 hrs to fix

        Function save has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        function save(id = null, type = null) {
            if (type === "cancel" && !confirm("Are you sure you want to cancel this Invoice?")) {
                return false;
            }
        
        
        Severity: Minor
        Found in source/javascript/admin/invoice.js - 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 update has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function update(Request $request, int $id): JsonResponse
            {
                $orm = app(OrmService::class);
        
                $category = $orm->getOne(Category::class, $id);
        Severity: Major
        Found in application/inc/Http/Controllers/Admin/CategoryController.php - About 2 hrs to fix

          Method cleanAddressData has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function cleanAddressData(array $data): array
              {
                  $data = [
                      'name'                 => $data['name'] ?? '',
                      'attn'                 => $data['attn'] ?? '',
          Severity: Minor
          Found in application/inc/Services/InvoiceService.php - About 2 hrs to fix

            Method getInvalid has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getInvalid(): array
                {
                    $invalid = [];
            
                    if (!$this->hasValidEmail()) {
            Severity: Minor
            Found in application/inc/Models/Invoice.php - About 2 hrs to fix

              Method generateFilterInvoiceBySelection has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function generateFilterInvoiceBySelection(InvoiceFilter $selected, User $user): string
                  {
                      if ($selected->id) {
                          return 'WHERE `id` = ' . $selected->id;
                      }
              Severity: Minor
              Found in application/inc/Http/Controllers/Admin/InvoiceController.php - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                        if (!$data['shipping_address2']
                            && ($data['shipping_phone'] === $data['phone1'] || $data['shipping_phone'] === $data['phone2'])
                            && $data['shipping_name'] === $data['name']
                            && $data['shipping_attn'] === $data['attn']
                            && $data['shipping_address'] === $data['address']
                Severity: Critical
                Found in application/inc/Services/InvoiceService.php - About 2 hrs to fix

                  Method create has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function create(Request $request): RedirectResponse
                      {
                          $fullname = $request->get('fullname');
                          $name = $request->getRequestString('name') ?? '';
                          $password = $request->getRequestString('password') ?? '';
                  Severity: Minor
                  Found in application/inc/Http/Controllers/Admin/UserController.php - About 1 hr to fix

                    Function prisUpdate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function prisUpdate() {
                        invoiceLines = [];
                        invoiceAmount = 0;
                    
                        var titles = document.getElementsByName("product");
                    Severity: Minor
                    Found in source/javascript/admin/invoice.js - 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 getPageData has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function getPageData(string $type, Page $page): array
                        {
                            $categories = $page->getCategories();
                            $paths = [];
                            $isVisible = false;
                    Severity: Minor
                    Found in application/inc/Http/Controllers/Admin/ExportController.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 results has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function results(Request $request): Response
                        {
                            if ($response = $this->checkSearchable($request)) {
                                return $response;
                            }
                    Severity: Minor
                    Found in application/inc/Http/Controllers/Search.php - About 1 hr to fix

                      Function prisUpdate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function prisUpdate() {
                          invoiceLines = [];
                          invoiceAmount = 0;
                      
                          var titles = document.getElementsByName("product");
                      Severity: Minor
                      Found in source/javascript/admin/invoice.js - About 1 hr to fix

                        Method fileRename has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function fileRename(Request $request, int $id): JsonResponse
                            {
                                try {
                                    $file = app(OrmService::class)->getOne(File::class, $id);
                                    if (!$file) {
                        Severity: Minor
                        Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 1 hr to fix

                          Method send has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function send(Request $request): Response
                              {
                                  $rawCart = $request->get('cart');
                                  if (!is_string($rawCart)) {
                                      $rawCart = '';
                          Severity: Minor
                          Found in application/inc/Http/Controllers/Shopping.php - About 1 hr to fix

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

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

                                public function send(): void
                                {
                                    if ($this->sent) {
                                        throw new Exception(_('The newsletter has already been sent.'));
                                    }
                            Severity: Minor
                            Found in application/inc/Models/Newsletter.php - About 1 hr to fix

                              Method sendInvoice has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function sendInvoice(Invoice $invoice): void
                                  {
                                      if (!$invoice->hasValidEmail()) {
                                          throw new InvalidInput(_('Email is not valid.'));
                                      }
                              Severity: Minor
                              Found in application/inc/Services/InvoiceService.php - About 1 hr to fix

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