serp-spider/search-engine-google

View on GitHub

Showing 35 of 47 total issues

Method parseItem has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function parseItem($localPack, GoogleDom $dom)
    {

        return [
            'title' => function () use ($localPack, $dom) {
Severity: Major
Found in src/Parser/Evaluated/Rule/Natural/Map.php - About 2 hrs to fix

    Method parseItem has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function parseItem($localPack, GoogleDom $dom)
        {
    
            return [
                'title' => function () use ($localPack, $dom) {
    Severity: Major
    Found in src/Parser/Evaluated/Rule/Natural/MapLegacy.php - About 2 hrs to fix

      Function parseGroups has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function parseGroups(DomNodeList $elementGroups, IndexedResultSet $resultSet, $googleDom)
          {
              $rules = $this->getRules();
      
              foreach ($elementGroups as $group) {
      Severity: Minor
      Found in src/Parser/AbstractParser.php - About 2 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 parseItem has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function parseItem(GoogleDom $googleDOM, \DOMNode $node)
          {
      
              return new BaseResult(AdwordsResultType::SHOPPING_GROUP_PRODUCT, [
                  'title' => function () use ($googleDOM, $node) {
      Severity: Minor
      Found in src/Parser/Evaluated/Rule/Adwords/Shopping.php - About 1 hr to fix

        Function getRelatedSearches has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getRelatedSearches()
            {
                $relatedSearches = [];
                if ($this->isMobile()) {
                    $items = $this->cssQuery('#botstuff div:not(#bres) a.QsZ7bb');
        Severity: Minor
        Found in src/Page/GoogleSerp.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 parse has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function parse(GoogleDom $googleDOM, \DomElement $node, IndexedResultSet $resultSet)
            {
                $item = [
                    'title' => function () use ($googleDOM, $node) {
                        $aTag = $googleDOM->getXpath()->query('descendant::h3/a[2]', $node)->item(0);
        Severity: Minor
        Found in src/Parser/Evaluated/Rule/Adwords/AdwordsItem.php - About 1 hr to fix

          Function parseItem has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function parseItem($localPack, GoogleDom $dom)
              {
          
                  return [
                      'title' => function () use ($localPack, $dom) {
          Severity: Minor
          Found in src/Parser/Evaluated/Rule/Natural/Map.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 parseItem has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function parseItem($localPack, GoogleDom $dom)
              {
          
                  return [
                      'title' => function () use ($localPack, $dom) {
          Severity: Minor
          Found in src/Parser/Evaluated/Rule/Natural/MapLegacy.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 match has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function match(GoogleDom $dom, DomElement $node)
              {
                  if ($node->childNodes->length == 1) {
                      $childNode = $node->getChildren()->getNodeAt(0);
          
          

          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 parseItem has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function parseItem($localPack, GoogleDom $dom)
              {
          
                  return [
                      'title' => function () use ($localPack, $dom) {
          Severity: Minor
          Found in src/Parser/Evaluated/Rule/Natural/MapMobile.php - About 1 hr to fix

            Method parseNode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function parseNode(GoogleDom $dom, \DOMElement $node)
                {
                    return [
                        'title'   => function () use ($dom, $node) {
                            $aTag = $dom->cssQuery('.rc .r a', $node)
            Severity: Minor
            Found in src/Parser/Evaluated/Rule/Natural/AnswerBox.php - About 1 hr to fix

              Method query has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function query(GoogleUrlInterface $googleUrl, BrowserInterface $browser = null)
                  {
              
                      if ($googleUrl->getResultType() !== GoogleUrl::RESULT_TYPE_ALL) {
                          throw new Exception(
              Severity: Minor
              Found in src/GoogleClient.php - About 1 hr to fix

                Function query has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function query(GoogleUrlInterface $googleUrl, BrowserInterface $browser = null)
                    {
                
                        if ($googleUrl->getResultType() !== GoogleUrl::RESULT_TYPE_ALL) {
                            throw new Exception(
                Severity: Minor
                Found in src/GoogleClient.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 parseNode has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function parseNode(GoogleDom $dom, DomElement $node)
                    {
                        return [
                            'title' => function () use ($dom, $node) {
                                return $dom

                  Method parseNode has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function parseNode(GoogleDom $dom, DomNodeInterface $node)
                      {
                          return [
                              'title' => function () use ($dom, $node) {
                                  return $dom

                    Method parseNode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function parseNode(GoogleDom $dom, \DomElement $node)
                        {
                    
                            // find the title/url
                            /* @var $aTag \DOMElement */
                    Severity: Minor
                    Found in src/Parser/Evaluated/Rule/Natural/Classical/ClassicalResult.php - About 1 hr to fix

                      Method parseNode has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function parseNode(GoogleDom $dom, DomNodeInterface $node)
                          {
                              return [
                                  'title' => function () use ($dom, $node) {
                                      return $dom

                        Method parse has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function parse(GoogleDom $dom, \DomElement $node, IndexedResultSet $resultSet)
                            {
                        
                                $item = new BaseResult(NaturalResultType::TWEETS_CAROUSEL, [
                        
                        
                        Severity: Minor
                        Found in src/Parser/Evaluated/Rule/Natural/TweetsCarouselZ1m.php - About 1 hr to fix

                          Method parse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function parse(GoogleDom $dom, \DomElement $node, IndexedResultSet $resultSet)
                              {
                                  $xpath = $dom->getXpath();
                                  $aTag = $xpath->query("descendant::h3[@class='r'][1]/a", $node)->item(0);
                          
                          

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

                                public function parse(GoogleDom $dom, \DomElement $node, IndexedResultSet $resultSet)
                                {
                                    $data = $this->parseNode($dom, $node);
                            
                                    $resultTypes = [NaturalResultType::CLASSICAL];
                            Severity: Minor
                            Found in src/Parser/Evaluated/Rule/Natural/Classical/ClassicalResult.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language