AJenbo/agcms

View on GitHub

Showing 1,189 of 1,190 total issues

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

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

                      var imageTileContextMenu = [{
                          "name": "Åbne",
                          "className": "picture",
                          callback(e) {
                              var id = getContextMenuTarget(e.target, "imagetile").id.match(/[0-9]+/g)[0];
                      Severity: Major
                      Found in source/javascript/admin/explorer.js and 2 other locations - About 1 hr to fix
                      source/javascript/admin/explorer.js on lines 100..107
                      source/javascript/admin/explorer.js on lines 144..151

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

                      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 3 locations. Consider refactoring.
                      Open

                          imageTileContextMenu.push({
                              "name": "Indsæt link",
                              "className": "link",
                              callback(e) {
                                  var id = getContextMenuTarget(e.target, "imagetile").id.match(/[0-9]+/g)[0];
                      Severity: Major
                      Found in source/javascript/admin/explorer.js and 2 other locations - About 1 hr to fix
                      source/javascript/admin/explorer.js on lines 100..107
                      source/javascript/admin/explorer.js on lines 134..141

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

                      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 3 locations. Consider refactoring.
                      Open

                          {
                            "name": "Åbne",
                            "className": "eye",
                            callback(e) {
                                var id = getContextMenuTarget(e.target, "filetile").id.match(/[0-9]+/g)[0];
                      Severity: Major
                      Found in source/javascript/admin/explorer.js and 2 other locations - About 1 hr to fix
                      source/javascript/admin/explorer.js on lines 134..141
                      source/javascript/admin/explorer.js on lines 144..151

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

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

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

                          function deletePage(navn, id) {
                              if (confirm("Vil du slette '" + navn + "'?")) {
                                  $("loading").style.visibility = "";
                                  xHttp.request("/admin/page/" + id + "/", removeElementByClass, "DELETE");
                              }
                          Severity: Major
                          Found in source/javascript/admin/index.js and 1 other location - About 1 hr to fix
                          source/javascript/admin/index.js on lines 192..197

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language