dolejska-daniel/riot-api-datadragon

View on GitHub

Showing 32 of 32 total issues

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

    public static function getStaticSummonerSpells( string $locale = 'en_US', string $version = null, bool $data_by_key = false ) : array
    {
        $url = self::getStaticDataFileUrl(self::STATIC_SUMMONERSPELLS, null, $locale, $version, $data_by_key ? self::STATIC_SUMMONERSPELLS_BY_KEY : null);
        return self::loadStaticData($url, [DataDragonAPI::class, "_summonerSpell"], $data_by_key);
    }
Severity: Minor
Found in src/DataDragonAPI/DataDragonAPI.php and 1 other location - About 55 mins to fix
src/DataDragonAPI/DataDragonAPI.php on lines 1308..1312

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

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 static function getStaticChampions( string $locale = 'en_US', string $version = null, bool $data_by_key = false ) : array
    {
        $url = self::getStaticDataFileUrl(self::STATIC_CHAMPIONS, null, $locale, $version, $data_by_key ? self::STATIC_CHAMPION_BY_KEY : null);
        return self::loadStaticData($url, [DataDragonAPI::class, "_champion"], $data_by_key);
    }
Severity: Minor
Found in src/DataDragonAPI/DataDragonAPI.php and 1 other location - About 55 mins to fix
src/DataDragonAPI/DataDragonAPI.php on lines 1553..1557

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

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 static function getStaticSummonerSpellById( string $summonerspell_id, string $locale = 'en_US', string $version = null ) : array
    {
        $data = self::getStaticSummonerSpells($locale, $version, true);
        if (isset($data['data'][$summonerspell_id]) == false)
            throw new ArgumentException("Summoner spell with ID '$summonerspell_id' was not found.", 404);
Severity: Minor
Found in src/DataDragonAPI/DataDragonAPI.php and 1 other location - About 45 mins to fix
src/DataDragonAPI/DataDragonAPI.php on lines 1360..1367

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

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 static function getStaticChampionByKey( int $champion_key, string $locale = 'en_US', string $version = null ) : array
    {
        $data = self::getStaticChampions($locale, $version, true);
        if (isset($data['data'][$champion_key]) == false)
            throw new ArgumentException("Champion with key '$champion_key' was not found.", 404);
Severity: Minor
Found in src/DataDragonAPI/DataDragonAPI.php and 1 other location - About 45 mins to fix
src/DataDragonAPI/DataDragonAPI.php on lines 1602..1609

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

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 getFromSprite has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function getFromSprite( string $source, int $x, int $y, int $w = 48, int $h = 48, array $attributes = [] ): Html
Severity: Minor
Found in src/DataDragonAPI/DataDragonAPI.php - About 45 mins to fix

    Method getStaticDataFileUrl has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public static function getStaticDataFileUrl( string $dataType, string $key = null, $locale = 'en_US', $version = null, string $fragment = null ): string
    Severity: Minor
    Found in src/DataDragonAPI/DataDragonAPI.php - About 35 mins to fix

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

          public static function getStaticSummonerSpell( string $summonerspell_key, string $locale = 'en_US', string $version = null ) : array
          {
              $data = self::getStaticSummonerSpells($locale, $version);
              if (isset($data['data'][$summonerspell_key]) == false)
                  throw new ArgumentException("Summoner spell with key '$summonerspell_key' was not found.", 404);
      Severity: Major
      Found in src/DataDragonAPI/DataDragonAPI.php and 4 other locations - About 30 mins to fix
      src/DataDragonAPI/DataDragonAPI.php on lines 1340..1347
      src/DataDragonAPI/DataDragonAPI.php on lines 1392..1399
      src/DataDragonAPI/DataDragonAPI.php on lines 1462..1469
      src/DataDragonAPI/DataDragonAPI.php on lines 1494..1501

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

      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 5 locations. Consider refactoring.
      Open

          public static function getStaticChampionById( string $champion_id, string $locale = 'en_US', string $version = null ) : array
          {
              $data = self::getStaticChampions($locale, $version);
              if (isset($data['data'][$champion_id]) == false)
                  throw new ArgumentException("Champion with ID '$champion_id' was not found.", 404);
      Severity: Major
      Found in src/DataDragonAPI/DataDragonAPI.php and 4 other locations - About 30 mins to fix
      src/DataDragonAPI/DataDragonAPI.php on lines 1392..1399
      src/DataDragonAPI/DataDragonAPI.php on lines 1462..1469
      src/DataDragonAPI/DataDragonAPI.php on lines 1494..1501
      src/DataDragonAPI/DataDragonAPI.php on lines 1568..1575

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

      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 5 locations. Consider refactoring.
      Open

          public static function getStaticItem( int $item_id, string $locale = 'en_US', string $version = null ) : array
          {
              $data = self::getStaticItems($locale, $version);
              if (isset($data['data'][$item_id]) == false)
                  throw new ArgumentException("Item with ID '$item_id' was not found.", 404);
      Severity: Major
      Found in src/DataDragonAPI/DataDragonAPI.php and 4 other locations - About 30 mins to fix
      src/DataDragonAPI/DataDragonAPI.php on lines 1340..1347
      src/DataDragonAPI/DataDragonAPI.php on lines 1462..1469
      src/DataDragonAPI/DataDragonAPI.php on lines 1494..1501
      src/DataDragonAPI/DataDragonAPI.php on lines 1568..1575

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

      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 5 locations. Consider refactoring.
      Open

          public static function getStaticRune( int $rune_id, string $locale = 'en_US', string $version = null) : array
          {
              $data = self::getStaticRunes($locale, $version);
              if (isset($data['data'][$rune_id]) == false)
                  throw new ArgumentException("Rune with ID '$rune_id' was not found.", 404);
      Severity: Major
      Found in src/DataDragonAPI/DataDragonAPI.php and 4 other locations - About 30 mins to fix
      src/DataDragonAPI/DataDragonAPI.php on lines 1340..1347
      src/DataDragonAPI/DataDragonAPI.php on lines 1392..1399
      src/DataDragonAPI/DataDragonAPI.php on lines 1462..1469
      src/DataDragonAPI/DataDragonAPI.php on lines 1568..1575

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

      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 5 locations. Consider refactoring.
      Open

          public static function getStaticMastery( int $mastery_id, string $locale = 'en_US', string $version = null ) : array
          {
              $data = self::getStaticMasteries($locale, $version);
              if (isset($data['data'][$mastery_id]) == false)
                  throw new ArgumentException("Mastery with ID '$mastery_id' was not found.", 404);
      Severity: Major
      Found in src/DataDragonAPI/DataDragonAPI.php and 4 other locations - About 30 mins to fix
      src/DataDragonAPI/DataDragonAPI.php on lines 1340..1347
      src/DataDragonAPI/DataDragonAPI.php on lines 1392..1399
      src/DataDragonAPI/DataDragonAPI.php on lines 1494..1501
      src/DataDragonAPI/DataDragonAPI.php on lines 1568..1575

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

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

          protected static function loadStaticData( string $url, callable $postprocess = null, bool $data_from_postprocess = false ): array
          {
              // Try loading from cache
              $data = self::loadCachedStaticData($url);
              if ($data->isHit()) return $data->get();
      Severity: Minor
      Found in src/DataDragonAPI/DataDragonAPI.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