serp-spider/search-engine-google

View on GitHub

Showing 47 of 47 total issues

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

<?php
/**
 * @license see LICENSE
 */

Severity: Major
Found in src/Parser/Evaluated/Rule/Natural/TopStoriesCarousel.php and 1 other location - About 1 day to fix
src/Parser/Evaluated/Rule/Natural/TopStoriesVertical.php on lines 1..68

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

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

<?php
/**
 * @license see LICENSE
 */

Severity: Major
Found in src/Parser/Evaluated/Rule/Natural/TopStoriesVertical.php and 1 other location - About 1 day to fix
src/Parser/Evaluated/Rule/Natural/TopStoriesCarousel.php on lines 1..69

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

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

    private function parseCarouselResults(GoogleDom $dom, DomElement $node)
    {
        $news = [];
        $nodes = $dom->cssQuery('._HSj ._ERj', $node);

Severity: Major
Found in src/Parser/Evaluated/Rule/Natural/ComposedTopStories.php and 1 other location - About 4 hrs to fix
src/Parser/Evaluated/Rule/Natural/ComposedTopStories.php on lines 59..78

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

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

    private function parseVerticalResults(GoogleDom $dom, DomElement $node)
    {
        $news = [];
        $nodes = $dom->cssQuery('.dbsr', $node);

Severity: Major
Found in src/Parser/Evaluated/Rule/Natural/ComposedTopStories.php and 1 other location - About 4 hrs to fix
src/Parser/Evaluated/Rule/Natural/ComposedTopStories.php on lines 80..99

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

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

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

                  'review' => function () use ($localPack, $dom) {
                      $review = $dom->cssQuery(
                          '.BTtC6e',
                          $localPack
                      )->getNodeAt(0);
      Severity: Major
      Found in src/Parser/Evaluated/Rule/Natural/MapMobile.php and 1 other location - About 1 hr to fix
      src/Parser/Evaluated/Rule/Natural/Map.php on lines 93..111

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

      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

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

                  'review' => function () use ($localPack, $dom) {
                      $review = $dom->cssQuery(
                          '.BTtC6e',
                          $localPack
                      )->getNodeAt(0);
      Severity: Major
      Found in src/Parser/Evaluated/Rule/Natural/Map.php and 1 other location - About 1 hr to fix
      src/Parser/Evaluated/Rule/Natural/MapMobile.php on lines 75..93

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

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

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

              protected function generateRules()
              {
                  return [
                      new Divider(),
                      new SearchResultGroup(),
          Severity: Major
          Found in src/Parser/Evaluated/MobileNaturalParser.php and 1 other location - About 1 hr to fix
          src/Parser/Evaluated/NaturalParser.php on lines 35..54

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

          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

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

              protected function generateRules()
              {
                  return [
                      new Divider(),
                      new SearchResultGroup(),
          Severity: Major
          Found in src/Parser/Evaluated/NaturalParser.php and 1 other location - About 1 hr to fix
          src/Parser/Evaluated/MobileNaturalParser.php on lines 36..55

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

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

          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

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