steadlane/silverstripe-searchify

View on GitHub

Showing 11 of 31 total issues

File Searchify.php has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class Searchify extends Object
{

Severity: Minor
Found in code/Searchify.php - About 3 hrs to fix

    Method addPage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function addPage($record)
        {
            if (!$this->index instanceof \Indextank_Index) {
                user_error(
                    _t(
    Severity: Minor
    Found in code/Searchify.php - About 1 hr to fix

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

          public function index(SS_HTTPRequest $r)
          {
              $results = Searchify::inst()->search($r->requestVar('q'));
              $resultStack = array();
      
      
      Severity: Minor
      Found in code/pages/SearchifyPageController.php - About 1 hr to fix

        Method addPages has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addPages($records)
            {
                if (!$records->count()) {
                    return false;
                }
        Severity: Minor
        Found in code/Searchify.php - About 1 hr to fix

          Method discover has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function discover($record)
              {
                  $config = \Config::inst()->get($record->ClassName, 'db');
          
                  $content = array(
          Severity: Minor
          Found in code/Searchify.php - About 1 hr to fix

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

                public function removePage($record)
                {
                    if (!$this->index instanceof \Indextank_Index) {
                        user_error(
                            _t(
            Severity: Minor
            Found in code/Searchify.php - About 1 hr to fix

              Method setIndex has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function setIndex($key)
                  {
                      $indexes = $this->getIndexList();
                      if (!isset($indexes[$key])) {
                          if (!$this->config()->make_index) {
              Severity: Minor
              Found in code/Searchify.php - About 1 hr to fix

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

                    public function discover($record)
                    {
                        $config = \Config::inst()->get($record->ClassName, 'db');
                
                        $content = array(
                Severity: Minor
                Found in code/Searchify.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 addPages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function addPages($records)
                    {
                        if (!$records->count()) {
                            return false;
                        }
                Severity: Minor
                Found in code/Searchify.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 indexAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function indexAll()
                    {
                        $pages = SiteTree::get();
                
                        if (!$pages) {
                Severity: Minor
                Found in code/Searchify.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function index(SS_HTTPRequest $r)
                    {
                        $results = Searchify::inst()->search($r->requestVar('q'));
                        $resultStack = array();
                
                
                Severity: Minor
                Found in code/pages/SearchifyPageController.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