AJenbo/agcms

View on GitHub

Showing 151 of 1,190 total issues

Function mailUsage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function mailUsage(): JsonResponse
    {
        $size = 0;

        foreach (ConfigService::getEmailConfigs() as $email) {
Severity: Minor
Found in application/inc/Http/Controllers/Admin/MaintenanceController.php - About 35 mins 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 addToCategory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addToCategory(Request $request, int $id, int $categoryId): JsonResponse
    {
        $orm = app(OrmService::class);

        $page = $orm->getOne(Page::class, $id);
Severity: Minor
Found in application/inc/Http/Controllers/Admin/PageController.php - About 35 mins 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 generateExtraNote has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateExtraNote(array $cart): string
    {
        $notes = [];
        switch ($cart['payMethod'] ?? '') {
            case 'creditcard':
Severity: Minor
Found in application/inc/Services/InvoiceService.php - About 35 mins 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

Avoid too many return statements within this function.
Open

    return false;
Severity: Major
Found in source/javascript/admin/index.js - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return sprintf(_('%s minutes and %s seconds ago'), $interval->i, $interval->s);
    Severity: Major
    Found in application/inc/Models/User.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return sprintf(_('%s hours and %s minutes ago'), $interval->h, $interval->i);
      Severity: Major
      Found in application/inc/Models/User.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return '';
        Severity: Major
        Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return sprintf(_('%s days and %s hours ago'), $interval->d, $interval->h);
          Severity: Major
          Found in application/inc/Models/User.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return "(
                                mime IN(
                                    'application/pdf',
                                    'application/msword',
                                    'application/vnd.ms-%',
            Severity: Major
            Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return "mime = 'application/zip'";
              Severity: Major
              Found in application/inc/Http/Controllers/Admin/ExplorerController.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return _('The payment was received and the package is sent.');
                Severity: Major
                Found in application/inc/Http/Controllers/Payment.php - About 30 mins to fix

                  Function handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handle(Request $request, callable $next): Response
                      {
                          $requestUrl = $request->getPathInfo();
                          if (0 !== mb_strpos($requestUrl, '/admin/') || '/admin/users/new/' === $requestUrl) {
                              return $next($request);
                  Severity: Minor
                  Found in application/inc/Http/Middleware/Auth.php - About 25 mins 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 getOpenCategories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getOpenCategories(array $openCategories, ?int $selectedId = null): array
                      {
                          if (null !== $selectedId) {
                              $category = app(OrmService::class)->getOne(Category::class, $selectedId);
                              if ($category) {
                  Severity: Minor
                  Found in application/inc/Services/SiteTreeService.php - About 25 mins 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 setShippingAddressVisability has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function setShippingAddressVisability(status) {
                      const rows = document.getElementsByTagName("tr");
                      for (const row of rows) {
                          if (row.className === "altpost") {
                              row.style.display = status ? "" : "none";
                  Severity: Minor
                  Found in source/javascript/site.js - About 25 mins 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 checkPageUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function checkPageUrl(Request $request, ?Category $category, ?Page $page): ?RedirectResponse
                      {
                          if (!$page || $page->isInactive()) {
                              if ($category && $category->getParent() && $category->isVisible()) {
                                  $status = $page ? Response::HTTP_FOUND : Response::HTTP_MOVED_PERMANENTLY;
                  Severity: Minor
                  Found in application/inc/Http/Controllers/Site.php - About 25 mins 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 send has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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 isVisible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function isVisible(): bool
                      {
                          if (self::HIDDEN === $this->renderMode) {
                              return false;
                          }
                  Severity: Minor
                  Found in application/inc/Models/Category.php - About 25 mins 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 setColumnData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function setColumnData(string $columnData): self
                      {
                          $columns = json_decode($columnData, true);
                  
                          if (is_array($columns)) {
                  Severity: Minor
                  Found in application/inc/Models/Table.php - About 25 mins 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 send has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __construct()
                      {
                          $app = app();
                          $templatePath = $app->basePath('/theme');
                          $loader = new FilesystemLoader('default/', $templatePath);
                  Severity: Minor
                  Found in application/inc/Services/RenderService.php - About 25 mins 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

                  Severity
                  Category
                  Status
                  Source
                  Language