beneggett/sportradar-api

View on GitHub
lib/sportradar/api/baseball/game.rb

Summary

Maintainability
F
3 days
Test Coverage

Class Game has 71 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Game < Data
        attr_accessor :response, :id, :title, :home_id, :away_id, :score, :status, :coverage, :scheduled, :venue, :broadcast, :duration, :attendance, :team_stats, :player_stats, :changes, :lineup

        attr_reader :inning, :half, :outs, :bases, :pitchers, :final, :rescheduled, :inning_over
        attr_reader :outcome, :count
Severity: Major
Found in lib/sportradar/api/baseball/game.rb - About 1 day to fix

    File game.rb has 402 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Sportradar
      module Api
        module Baseball
          class Game < Data
            attr_accessor :response, :id, :title, :home_id, :away_id, :score, :status, :coverage, :scheduled, :venue, :broadcast, :duration, :attendance, :team_stats, :player_stats, :changes, :lineup
    Severity: Minor
    Found in lib/sportradar/api/baseball/game.rb - About 5 hrs to fix

      Method update has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

              def update(data, source: nil, **opts)
                @response.merge!(data)
                # via pbp
                @status       = data['status']                if data['status']
                @coverage     = data['coverage']              if data['coverage']
      Severity: Minor
      Found in lib/sportradar/api/baseball/game.rb - 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

      Method update_bases has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              def update_bases(data)
                if data.is_a?(Sportradar::Api::Baseball::Error)
                  puts data.inspect
                  return
                end
      Severity: Minor
      Found in lib/sportradar/api/baseball/game.rb - 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 update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def update(data, source: nil, **opts)
                @response.merge!(data)
                # via pbp
                @status       = data['status']                if data['status']
                @coverage     = data['coverage']              if data['coverage']
      Severity: Minor
      Found in lib/sportradar/api/baseball/game.rb - About 1 hr to fix

        Method advance_inning has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def advance_inning
                  @inning_over = false
                  return unless count['outs'] == 3
                  if count['inning'] >= 9
                    if count['inning_half'] == 'T' && leading_team_id == home.id
        Severity: Minor
        Found in lib/sportradar/api/baseball/game.rb - 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 realtime_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def realtime_state(full_word: false)
                  if future?
                    'Scheduled'
                  elsif delayed?
                    'Delayed'
        Severity: Minor
        Found in lib/sportradar/api/baseball/game.rb - 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

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

                def inning_short
                  if !count.empty?
                    inning_half = self.count['inning_half']
                    inning = self.count['inning']
                    "#{half_short} #{ordinalize_inning(inning || 1)}" # TODO remove AS dependency
        Severity: Minor
        Found in lib/sportradar/api/baseball/game.rb and 1 other location - About 15 mins to fix
        lib/sportradar/api/baseball/game.rb on lines 328..332

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

        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

                def inning_word
                  if !count.empty?
                    inning_half = self.count['inning_half']
                    inning = self.count['inning']
                    "#{half_word} #{ordinalize_inning(inning || 1)}"
        Severity: Minor
        Found in lib/sportradar/api/baseball/game.rb and 1 other location - About 15 mins to fix
        lib/sportradar/api/baseball/game.rb on lines 320..324

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

        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

                  @away         = Team.new(data['away'] || data.dig('scoring', 'away'), api: api, game: self) if data['away'] || data.dig('scoring', 'away')
                  @title        = data['title'] || @title || (home && away && "#{home.full_name} vs #{away.full_name}")
        Severity: Minor
        Found in lib/sportradar/api/baseball/game.rb and 1 other location - About 15 mins to fix
        lib/sportradar/api/baseball/game.rb on lines 124..125

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

        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

                  @home         = Team.new(data['home'] || data.dig('scoring', 'home'), api: api, game: self) if data['home'] || data.dig('scoring', 'home')
                  @away         = Team.new(data['away'] || data.dig('scoring', 'away'), api: api, game: self) if data['away'] || data.dig('scoring', 'away')
        Severity: Minor
        Found in lib/sportradar/api/baseball/game.rb and 1 other location - About 15 mins to fix
        lib/sportradar/api/baseball/game.rb on lines 125..126

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

        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

        There are no issues that match your filters.

        Category
        Status