thcolin/senscritique-api

View on GitHub

Showing 8 of 10 total issues

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

  public function findNextNodeByText(DiDomElement $element, $expression, $grep = false){
    $childNodes = $element->getNode()->childNodes;
    $length = $childNodes->length;
    $stop = false;

Severity: Minor
Found in src/Document.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 getYear has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  public function getYear(){
    if($elements = $this->find('.d-grid-aside')){
      if($document = $this->findNextNodeByText($elements[0], 'Année de production')){
        return intval($document->text());
      } else if($document = $this->findNextNodeByText($elements[0], '#Première diffusion#', true)){
Severity: Minor
Found in src/Models/Artwork.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 getGenres has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  public function getGenres($array = false){
    $genres = [];

    if($elements = $this->find('.d-grid-aside')){
      if($element = $this->findNextNodeByText($elements[0], 'Genre')){
Severity: Minor
Found in src/Models/Artwork.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

Function getDocumentByURI has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  public function getDocumentByURI($args){
    $uris = (is_array($args) ? $args:[$args]);
    $dp = new Dispatcher();
    $requests = $documents = [];

Severity: Minor
Found in src/Core/API.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

Function getDirectors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  public function getDirectors($array = false){
    $directors = [];

    if($elements = $this->find('.d-grid-main')){
      if($element = $this->findNextNodeByText($elements[0], '#Réalisateur|Créateurs#', true)){
Severity: Minor
Found in src/Models/Artwork.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 getActors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  public function getActors($array = false){
    $actors = [];

    if($elements = $this->find('.d-grid-main .d-rubric')){
      if($element = $this->findNextNodeByText($elements[0], '#Acteurs#', true)){
Severity: Minor
Found in src/Models/Artwork.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 getTitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  public function getTitle($type = self::TITLE_DEFAULT){
    if($type == self::TITLE_DEFAULT && $elements = $this->find('.pco-cover-title')){
      return trim($elements[0]->text());
    } else if($type == self::TITLE_ORIGINAL && $elements = $this->find('.d-grid-aside')){
      $element = $this->findNextNodeByText($elements[0], 'Titre original');
Severity: Minor
Found in src/Models/Artwork.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

Function offsetSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  public function offsetSet($key, $element){
    if(!isset($element['class']) && !isset($element['uri'])){
      throw new CollectionElementException('A collection element must contain "class" and "uri" keys');
    } else if(is_null($key)){
      $this->container[] = $element;
Severity: Minor
Found in src/DynamicArray.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