razielsd/phpSelenide

View on GitHub

Showing 128 of 128 total issues

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

    public function asString()
    {
        $locator = '';
        switch ($this->type) {
            case self::TYPE_NAME:
Severity: Major
Found in lib/Selenide/By.php and 1 other location - About 1 day to fix
lib/Selenide/By.php on lines 153..187

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

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

    public function getChildLocator()
    {
        $locator = '';
        switch ($this->type) {
            case self::TYPE_NAME:
Severity: Major
Found in lib/Selenide/By.php and 1 other location - About 1 day to fix
lib/Selenide/By.php on lines 116..150

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

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

namespace Selenide;

use PHPUnit\Framework\Assert;
Severity: Major
Found in lib/Selenide/Condition/Enabled.php and 1 other location - About 6 hrs to fix
lib/Selenide/Condition/Checked.php on lines 1..50

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

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

namespace Selenide;

use PHPUnit\Framework\Assert;
Severity: Major
Found in lib/Selenide/Condition/Checked.php and 1 other location - About 6 hrs to fix
lib/Selenide/Condition/Enabled.php on lines 1..50

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

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

ElementsCollection has 39 functions (exceeds 20 allowed). Consider refactoring.
Open

class ElementsCollection implements Iterator, Countable, ArrayAccess
{
    const MODE_SINGLE_ELEMENT = 1;
    const MODE_COLLECTION_ELEMENT = 2;

Severity: Minor
Found in lib/Selenide/ElementsCollection.php - About 5 hrs to fix

    File ElementsCollection.php has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Selenide;
    
    use ArrayAccess;
    Severity: Minor
    Found in lib/Selenide/ElementsCollection.php - About 3 hrs to fix

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

          public function assertCollectionNegative(array $elementList)
          {
              if (empty($elementList)) {
                  throw new Exception_ElementNotFound('Elements not found for assertion');
              }
      Severity: Major
      Found in lib/Selenide/Condition/Attribute.php and 1 other location - About 3 hrs to fix
      lib/Selenide/Condition/Attribute.php on lines 39..60

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

      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

          public function assertCollectionPositive(array $elementList)
          {
              if (empty($elementList)) {
                  throw new Exception_ElementNotFound('Elements not found for assertion');
              }
      Severity: Major
      Found in lib/Selenide/Condition/Attribute.php and 1 other location - About 3 hrs to fix
      lib/Selenide/Condition/Attribute.php on lines 63..83

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

      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

      The class ElementsCollection has an overall complexity of 65 which is very high. The configured complexity threshold is 50.
      Open

      class ElementsCollection implements Iterator, Countable, ArrayAccess
      {
          const MODE_SINGLE_ELEMENT = 1;
          const MODE_COLLECTION_ELEMENT = 2;
      
      
      Severity: Minor
      Found in lib/Selenide/ElementsCollection.php by phpmd

      The class Condition has 14 public methods. Consider refactoring Condition to keep number of public methods under 10.
      Open

      class Condition
      {
          /**
           * Checks that collection has the given size
           *
      Severity: Minor
      Found in lib/Selenide/Condition.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class ElementsCollection has 32 non-getter- and setter-methods. Consider refactoring ElementsCollection to keep number of methods under 25.
      Open

      class ElementsCollection implements Iterator, Countable, ArrayAccess
      {
          const MODE_SINGLE_ELEMENT = 1;
          const MODE_COLLECTION_ELEMENT = 2;
      
      
      Severity: Minor
      Found in lib/Selenide/ElementsCollection.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanymethods

      The class ElementsCollection has 30 public methods. Consider refactoring ElementsCollection to keep number of public methods under 10.
      Open

      class ElementsCollection implements Iterator, Countable, ArrayAccess
      {
          const MODE_SINGLE_ELEMENT = 1;
          const MODE_COLLECTION_ELEMENT = 2;
      
      
      Severity: Minor
      Found in lib/Selenide/ElementsCollection.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class SelectorList has 11 public methods. Consider refactoring SelectorList to keep number of public methods under 10.
      Open

      class SelectorList implements \ArrayAccess, \Countable, \Iterator
      {
          /**
           * @var Selector[]
           */
      Severity: Minor
      Found in lib/Selenide/SelectorList.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class SelenideElement has 11 public methods. Consider refactoring SelenideElement to keep number of public methods under 10.
      Open

      class SelenideElement
      {
          /**
           * @var \WebDriver_Element
           */
      Severity: Minor
      Found in lib/Selenide/SelenideElement.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      Function match has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function match($collection, $isPositive = true){
              $result = [];
              if ($this instanceof Condition_Interface_ExpectedCollection) {
                  $expected = $this->matchCollection($collection);
                  $expected = $isPositive ? $expected : !$expected;
      Severity: Minor
      Found in lib/Selenide/Condition/Rule.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

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

          public function assertCollectionPositive(array $elementList)
          {
              if (empty($elementList)) {
                  throw new Exception_ElementNotFound('Elements not found for assertion');
              }
      Severity: Major
      Found in lib/Selenide/Condition/MatchText.php and 1 other location - About 1 hr to fix
      lib/Selenide/Condition/MatchText.php on lines 42..57

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

      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

          public function assertCollectionNegative(array $elementList)
          {
              if (empty($elementList)) {
                  throw new Exception_ElementNotFound('Elements not found for assertion');
              }
      Severity: Major
      Found in lib/Selenide/Condition/MatchText.php and 1 other location - About 1 hr to fix
      lib/Selenide/Condition/MatchText.php on lines 24..39

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

      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 searchBySelectors has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function searchBySelectors(SelectorList $selectorList)
          {
              $this->selenide->getReport()
                  ->addRootEvent('Search element: ' . $selectorList->getLocator());
              $resultList = [];
      Severity: Minor
      Found in lib/Selenide/Driver.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

      Avoid excessively long variable names like $substringsWithoutDoubleQuotes. Keep variable name length under 20.
      Open

                  $substringsWithoutDoubleQuotes = explode('"', $toEscape);
      Severity: Minor
      Found in lib/Selenide/By.php by phpmd

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#longvariable

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

          public function assertCollectionPositive(array $elementList)
          {
              if (empty($elementList)) {
                  throw new Exception_ElementNotFound('Elements not found for assertion');
              }
      Severity: Major
      Found in lib/Selenide/Condition/WithText.php and 3 other locations - About 1 hr to fix
      lib/Selenide/Condition/Text.php on lines 19..34
      lib/Selenide/Condition/Text.php on lines 37..52
      lib/Selenide/Condition/WithText.php on lines 37..52

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

      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

      Severity
      Category
      Status
      Source
      Language