gloireTR/Anidb

View on GitHub

Showing 24 of 24 total issues

Function getAnimes has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAnimes(){
        $dom = new DOMDocument();
        libxml_use_internal_errors(true);
        $control = '';
        preg_match_all(parent::PATTERN_CREATOR_ANIMES . $this->creator_id . parent::PATTERN_SECOND_CREATOR_ANIMES, $this->html, $arr);
Severity: Minor
Found in src/creators/creators.php - About 1 day 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

        if (!empty($directArr[0])) {
            $del = explode('/', $directArr[3][0]);
            $firstKey = end($del);
            $firstValue = $directArr[4][0];
Severity: Major
Found in src/anime/Anime.php and 1 other location - About 1 day to fix
src/anime/Anime.php on lines 206..230

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

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

        if (!empty($similarArray[0])) {
            $del = explode('/', $similarArray[3][0]);
            $firstKey = end($del);
            $firstValue = $similarArray[4][0];
Severity: Major
Found in src/anime/Anime.php and 1 other location - About 1 day to fix
src/anime/Anime.php on lines 176..200

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

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

        foreach ($tr as $t) {
            $childTr = $t->childNodes;
            foreach ($childTr as $ts) {
                if ($ts->nodeName == 'th') {
                    array_push($keys, strtolower($ts->nodeValue));
Severity: Major
Found in src/characters/characters.php and 1 other location - About 6 hrs to fix
src/creators/creators.php on lines 80..103

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

            foreach ($tr as $t){
                $test = $t->childNodes;
                foreach ($test as $ts){
                    if ($ts->nodeName == 'th'){
                        array_push($keys, strtolower($ts->nodeValue));
Severity: Major
Found in src/creators/creators.php and 1 other location - About 6 hrs to fix
src/characters/characters.php on lines 72..96

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

Function getCreator has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function getCreator()
    {
        $dom = new DOMDocument();
        libxml_use_internal_errors(true);
        $dom->loadHTML($this->html);
Severity: Minor
Found in src/characters/characters.php - About 4 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

Function getInfo has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function getInfo(){
        preg_match_all(parent::PATTERN_CREATOR_INFO, $this->html, $arr);
        if (!isset($arr[0][0]) || empty($arr[0][0])){
            return 'null';
        }else{
Severity: Minor
Found in src/creators/creators.php - About 4 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

File Anime.php has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Class AnidbAnime
 * @brief Anime Setup
 * @author gloire
Severity: Minor
Found in src/anime/Anime.php - About 4 hrs to fix

    Function getRelatedAnimes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRelatedAnimes(){
            $dom = new DOMDocument();
            libxml_use_internal_errors(true);
            preg_match_all(parent::PATTERN_CHAR_RELATED, $this->html, $arr);
            if (!isset($arr[2][0])){
    Severity: Minor
    Found in src/characters/characters.php - About 4 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

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

        public function getInfo()
        {
            preg_match_all(parent::PATTERN_CHAR_INFO, $this->html, $arr);
            $dom = new DOMDocument();
            libxml_use_internal_errors(true);
    Severity: Minor
    Found in src/characters/characters.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

    Function getStaff has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getStaff()
        {
            preg_match_all(parent::PATTERN_STAFF, $this->html, $exArray);
            if (isset($exArray[1][0]) && isset($exArray[2][0])) {
                $firstId = $exArray[1][0];
    Severity: Minor
    Found in src/anime/Anime.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 getAnimes has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getAnimes(){
            $dom = new DOMDocument();
            libxml_use_internal_errors(true);
            $control = '';
            preg_match_all(parent::PATTERN_CREATOR_ANIMES . $this->creator_id . parent::PATTERN_SECOND_CREATOR_ANIMES, $this->html, $arr);
    Severity: Major
    Found in src/creators/creators.php - About 2 hrs to fix

      Method getStaff has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getStaff()
          {
              preg_match_all(parent::PATTERN_STAFF, $this->html, $exArray);
              if (isset($exArray[1][0]) && isset($exArray[2][0])) {
                  $firstId = $exArray[1][0];
      Severity: Major
      Found in src/anime/Anime.php - About 2 hrs to fix

        Anime has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class Anime extends Options
        {
            /**
             * @param $cloud_name
             * @param $key
        Severity: Minor
        Found in src/anime/Anime.php - About 2 hrs to fix

          Method getCreator has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getCreator()
              {
                  $dom = new DOMDocument();
                  libxml_use_internal_errors(true);
                  $dom->loadHTML($this->html);
          Severity: Major
          Found in src/characters/characters.php - About 2 hrs to fix

            Method getCharacters has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getCharacters()
                {
                    preg_match_all(parent::PATTERN_CHARACTERS, $this->html, $mainCharArray);
                    if (!empty($mainCharArray[0])) {
                        $firstCharId = $mainCharArray[7][0];
            Severity: Minor
            Found in src/anime/Anime.php - About 1 hr to fix

              Method getInfo has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getInfo(){
                      preg_match_all(parent::PATTERN_CREATOR_INFO, $this->html, $arr);
                      if (!isset($arr[0][0]) || empty($arr[0][0])){
                          return 'null';
                      }else{
              Severity: Minor
              Found in src/creators/creators.php - About 1 hr to fix

                Method getRelatedAnimes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getRelatedAnimes(){
                        $dom = new DOMDocument();
                        libxml_use_internal_errors(true);
                        preg_match_all(parent::PATTERN_CHAR_RELATED, $this->html, $arr);
                        if (!isset($arr[2][0])){
                Severity: Minor
                Found in src/characters/characters.php - About 1 hr to fix

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

                      public function getCast()
                      {
                          preg_match_all(parent::PATTERN_CAST, $this->html, $castArray);
                          if (!empty($castArray[0])) {
                              $firstCastId = $castArray[2][0];
                  Severity: Minor
                  Found in src/anime/Anime.php - About 1 hr to fix

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

                        public function getInfo()
                        {
                            preg_match_all(parent::PATTERN_CHAR_INFO, $this->html, $arr);
                            $dom = new DOMDocument();
                            libxml_use_internal_errors(true);
                    Severity: Minor
                    Found in src/characters/characters.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language