AJenbo/agcms

View on GitHub

Showing 1,189 of 1,190 total issues

File index.js has 906 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import xHttp from "../xHttp.js";
import {
    genericCallback,
    reloadCallback,
    injectHtml,
Severity: Major
Found in source/javascript/admin/index.js - About 2 days to fix

    Invoice has 92 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Invoice extends AbstractEntity
    {
        /** Table name in database. */
        public const TABLE_NAME = 'fakturas';
    
    
    Severity: Major
    Found in application/inc/Models/Invoice.php - About 1 day to fix

      Function index has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
      Open

          public function index(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/ExportController.php - About 1 day 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

      File Invoice.php has 709 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace App\Models;
      
      use App\DTO\InvoiceItem;
      Severity: Major
      Found in application/inc/Models/Invoice.php - About 1 day to fix

        Function createFromCart has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
        Open

            public function createFromCart(array $cart): Invoice
            {
                $db = app(DbService::class);
                $orm = app(OrmService::class);
                $amount = 0;
        Severity: Minor
        Found in application/inc/Services/InvoiceService.php - About 1 day 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

        File ExplorerController.php has 591 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace App\Http\Controllers\Admin;
        
        use App\Exceptions\Exception;
        Severity: Major
        Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 1 day to fix

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

          function getAddressCallback1(responce) {
              if (responce.error) {
                  return;
              }
              if (responce.name) {
          Severity: Major
          Found in source/javascript/site.js and 1 other location - About 1 day to fix
          source/javascript/site.js on lines 115..138

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

          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

          function getAddressCallback2(responce) {
              if (responce.error) {
                  return;
              }
              if (responce.name) {
          Severity: Major
          Found in source/javascript/site.js and 1 other location - About 1 day to fix
          source/javascript/site.js on lines 90..113

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

          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

          Method getCountries has 226 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function getCountries(): array
              {
                  return [
                      'DK' => _('Denmark'),
                      'FI' => _('Finland'),
          Severity: Major
          Found in application/inc/Countries.php - About 1 day to fix

            File explorer.js has 430 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import xHttp from "../xHttp.js";
            import File from "./File.js";
            import openPopup from "./openPopup.js";
            import {injectHtml, setCookie, getCookie, htmlEncode, removeTagById} from "./javascript.js";
            import * as Sentry from '@sentry/browser';
            Severity: Minor
            Found in source/javascript/admin/explorer.js - About 6 hrs to fix

              Page has 43 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Page extends AbstractRenderable implements InterfaceRichText
              {
                  use HasIcon;
              
                  /** Table name in database. */
              Severity: Minor
              Found in application/inc/Models/Page.php - About 5 hrs to fix

                Method load has 139 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function load(Application $app): void
                    {
                        $app->middleware([Utf8Url::class, Auth::class]);
                        if ($app->environment('develop')) {
                            $app->middleware(Placekitten::class);
                Severity: Major
                Found in application/inc/Routes.php - About 5 hrs to fix

                  Function buildSearchQuery has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function buildSearchQuery(string $qpath, string $qalt, string $qtype): string
                      {
                          $db = app(DbService::class);
                          $qpath = $db->escapeWildcards($qpath);
                          $qalt = $db->escapeWildcards($qalt);
                  Severity: Minor
                  Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 5 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

                  File InvoiceService.php has 378 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace App\Services;
                  
                  use App\Countries;
                  Severity: Minor
                  Found in application/inc/Services/InvoiceService.php - About 5 hrs to fix

                    Function invoiceBasicUpdate has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function invoiceBasicUpdate(Invoice $invoice, User $user, InvoiceAction $action, array $updates): void
                        {
                            $status = $invoice->getStatus();
                    
                            if (InvoiceStatus::New === $invoice->getStatus()) {
                    Severity: Minor
                    Found in application/inc/Services/InvoiceService.php - About 4 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

                    File Payment.php has 357 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    namespace App\Http\Controllers;
                    
                    use App\Countries;
                    Severity: Minor
                    Found in application/inc/Http/Controllers/Payment.php - About 4 hrs to fix

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

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

                        File MaintenanceController.php has 326 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        
                        namespace App\Http\Controllers\Admin;
                        
                        use AJenbo\Imap;
                        Severity: Minor
                        Found in application/inc/Http/Controllers/Admin/MaintenanceController.php - About 3 hrs to fix

                          File Page.php has 326 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          
                          namespace App\Models;
                          
                          use App\Exceptions\Exception;
                          Severity: Minor
                          Found in application/inc/Models/Page.php - About 3 hrs to fix

                            Method invoiceBasicUpdate has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function invoiceBasicUpdate(Invoice $invoice, User $user, InvoiceAction $action, array $updates): void
                                {
                                    $status = $invoice->getStatus();
                            
                                    if (InvoiceStatus::New === $invoice->getStatus()) {
                            Severity: Major
                            Found in application/inc/Services/InvoiceService.php - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language