Kylob/Sitemap

View on GitHub

Showing 11 of 11 total issues

Function page has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    public static function page($limit = 10000, $expires = 0)
    {
        $page = Page::html();
        if (preg_match('/^sitemap(\-(?P<category>[a-z-]+)(\-(?P<num>[0-9]+))?)?\.xml$/i', $page->url['path'], $xml)) {
            $last_modified = 0;
Severity: Minor
Found in src/Component.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 Component.php has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace BootPress\Sitemap;

use BootPress\Page\Component as Page;
Severity: Minor
Found in src/Component.php - About 4 hrs to fix

    Method page has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function page($limit = 10000, $expires = 0)
        {
            $page = Page::html();
            if (preg_match('/^sitemap(\-(?P<category>[a-z-]+)(\-(?P<num>[0-9]+))?)?\.xml$/i', $page->url['path'], $xml)) {
                $last_modified = 0;
    Severity: Major
    Found in src/Component.php - About 3 hrs to fix

      Function exec has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          private function exec($action, $table, $values)
          {
              $action = strtolower($action);
              if (!isset($this->stmt[$action][$table])) {
                  if ($this->transaction === false && $action != 'select') {
      Severity: Minor
      Found in src/Component.php - About 3 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 exec has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function exec($action, $table, $values)
          {
              $action = strtolower($action);
              if (!isset($this->stmt[$action][$table])) {
                  if ($this->transaction === false && $action != 'select') {
      Severity: Minor
      Found in src/Component.php - About 1 hr to fix

        Method __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct()
            {
                $page = Page::html();
                $this->db = new SQLite($page->file('Sitemap.db'));
                if ($this->db->created) {
        Severity: Minor
        Found in src/Component.php - About 1 hr to fix

          Function upsert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function upsert($category, array $save)
              {
                  $sitemap = array();
                  $save['category'] = $category;
                  $updated = (isset($save['updated']) && is_numeric($save['updated'])) ? abs($save['updated']) : time();
          Severity: Minor
          Found in src/Component.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

          Function delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function delete($path = null)
              {
                  if ($path) {
                      if ($row = $this->exec('SELECT', 'sitemap', $path)) {
                          $this->exec('DELETE', 'search', $row['docid']);
          Severity: Minor
          Found in src/Component.php - About 55 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 id has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private function id($category)
              {
                  if (is_null($this->ids)) {
                      $this->ids = array();
                      $categories = $this->db->all('SELECT category, id FROM categories', '', 'assoc');
          Severity: Minor
          Found in src/Component.php - About 55 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 search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function search($phrase, $category = '', $limit = '', array $weights = array(), $where = '')
              {
                  $page = Page::html();
                  $fields = array('s.path', 's.title', 's.description', 's.keywords', 's.content AS search', 'c.category', 'm.path AS url', 'm.info', 'm.image', 'm.updated', 'm.content');
                  $weights = array_slice(array_pad($weights, 5, 1), 0, 5);
          Severity: Minor
          Found in src/Component.php - About 45 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

          Method search has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function search($phrase, $category = '', $limit = '', array $weights = array(), $where = '')
          Severity: Minor
          Found in src/Component.php - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language