AJenbo/agcms

View on GitHub

Showing 1,189 of 1,190 total issues

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

function deleteCategory(navn, id) {
    if (confirm("Vil du slette katagorien '" + navn + "'?")) {
        $("loading").style.visibility = "";
        xHttp.request("/admin/categories/" + id + "/", deleteCallback, "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 137..142

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

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

    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

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

            if (confirm("Vil du fjerne '" + navn + "' som tilbehor?")) {
                $("loading").style.visibility = "";
                xHttp.request("/admin/page/" + pageId + "/accessories/" + accessoryId + "/", deleteCallback, "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 201..204

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

        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

            if (confirm("Vil du fjerne siden fra '" + navn + "'?")) {
                $("loading").style.visibility = "";
                xHttp.request("/admin/page/" + id + "/categories/" + categoryId + "/", callback, "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 392..395

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

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

          The class Invoice has 38 fields. Consider redesigning Invoice to keep the number of fields under 15.
          Open

          class Invoice extends AbstractEntity
          {
              /** Table name in database. */
              public const TABLE_NAME = 'fakturas';
          
          
          Severity: Minor
          Found in application/inc/Models/Invoice.php by phpmd

          TooManyFields

          Since: 0.1

          Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

          Example

          class Person {
             protected $one;
             private $two;
             private $three;
             [... many more fields ...]
          }

          Source https://phpmd.org/rules/codesize.html#toomanyfields

          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

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

                            public function sendReminder(Request $request, int $id): JsonResponse
                            {
                                $invoice = app(OrmService::class)->getOne(Invoice::class, $id);
                                if (!$invoice) {
                                    throw new InvalidInput(_('Invoice not found.'), Response::HTTP_NOT_FOUND);
                        application/inc/Http/Controllers/Admin/InvoiceController.php on lines 309..320
                        application/inc/Http/Controllers/Admin/InvoiceController.php on lines 325..336

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

                        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

                            public function annulPayment(Request $request, int $id): JsonResponse
                            {
                                $invoice = app(OrmService::class)->getOne(Invoice::class, $id);
                                if (!$invoice) {
                                    throw new InvalidInput(_('Invoice not found.'), Response::HTTP_NOT_FOUND);
                        application/inc/Http/Controllers/Admin/InvoiceController.php on lines 293..304
                        application/inc/Http/Controllers/Admin/InvoiceController.php on lines 309..320

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

                        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

                            public function capturePayment(Request $request, int $id): JsonResponse
                            {
                                $invoice = app(OrmService::class)->getOne(Invoice::class, $id);
                                if (!$invoice) {
                                    throw new InvalidInput(_('Invoice not found.'), Response::HTTP_NOT_FOUND);
                        application/inc/Http/Controllers/Admin/InvoiceController.php on lines 293..304
                        application/inc/Http/Controllers/Admin/InvoiceController.php on lines 325..336

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

                        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 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
                          Severity
                          Category
                          Status
                          Source
                          Language