beneggett/sportradar-api

View on GitHub

Showing 185 of 185 total issues

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

        def update(data, source: nil, **opts)
          # update stuff
          @id     = data['id'] if data['id']
          @season = data['season']  if data['season']
          @type   = data['type']    if data['type']
Severity: Minor
Found in lib/sportradar/api/football/ncaafb.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 end_reason_possibilities has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def end_reason_possibilities
          [
            'UNKNOWN',
            'Touchdown',
            'Safety',
Severity: Minor
Found in lib/sportradar/api/football/drive.rb - About 1 hr to fix

    Method tournament_ids has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def self.tournament_ids
              @tournament_ids ||= {
                # Europe group
                'eu.uefa_champions_league'  => "sr:tournament:7",
                'eu.la_liga'                => "sr:tournament:8",
    Severity: Minor
    Found in lib/sportradar/api/soccer/tournament.rb - About 1 hr to fix

      Method initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def initialize(data)
                @response       = data
                @id             = data["id"]
                @type           = data["type"]
                @time           = data["time"]
      Severity: Minor
      Found in lib/sportradar/api/soccer/fact.rb - About 1 hr to fix

        Method tournament_ids has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def self.tournament_ids
                  @tournament_ids ||= {
                    # Europe group
                    'eu.uefa_champions_league'  => "sr:tournament:7",
                    'eu.la_liga'                => "sr:tournament:8",
        Severity: Minor
        Found in lib/sportradar/api/soccer/competition.rb - About 1 hr to fix

          Method parse_description_for_drive_end has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def parse_description_for_drive_end
                      parsed_ending = case @description
                      when /no play/i
                        nil
                      when /intercepted/i
          Severity: Minor
          Found in lib/sportradar/api/football/ncaafb/play.rb - About 1 hr to fix

            Method update has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def update(data, **opts)
                      @id             = data['id']             if data['id']
                      @league_group = opts[:league_group] || data['league_group'] || @league_group
            
                      if data['player']
            Severity: Minor
            Found in lib/sportradar/api/soccer/player.rb - About 1 hr to fix

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

                      def parse_from_pbp(data)
                        scoring = data['innings'].map {|i| i['scoring'] }.compact
                        return {} if scoring.empty?
                        scoring.each_with_object({}).with_index(1) do |(hash, memo), idx|
                          memo[idx] = {hash.dig('home', 'id') => hash.dig('home', 'runs'), hash.dig('away', 'id') => hash.dig('away', 'runs')}
              Severity: Minor
              Found in lib/sportradar/api/baseball/scoring.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/baseball/outcome.rb on lines 35..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 46.

              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

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

                      def parse_from_pbp(data)
                        scoring = data['innings'].map {|i| i['scoring'] }.compact
                        return {} if scoring.empty?
                        scoring.each_with_object({}).with_index(1) do |(hash, memo), idx|
                          memo[idx] = {hash.dig('home', 'id') => hash.dig('home', 'runs'), hash.dig('away', 'id') => hash.dig('away', 'runs')}
              Severity: Minor
              Found in lib/sportradar/api/baseball/outcome.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/baseball/scoring.rb on lines 59..63

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

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

                      def next_batters(team, number_of_upcoming_batters = 3)
                        if team == 'home'
                          last_at_bat = game.at_bats.select{|at_bat| at_bat.event.half_inning.half == 'B'}.last
                          if last_at_bat
                            last_position = @home.detect{|htl| htl['id'] == last_at_bat.hitter_id}&.dig('order')
              Severity: Minor
              Found in lib/sportradar/api/baseball/lineup.rb - 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

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

                      def update(data, **opts)
                        @round       = data['round']       if data['round']       # "3",
                        @time        = data['time']        if data['time']        # "05:00",
                        @outcome     = data['method']      if data['method']      # "Decision - Split",
                        @submission  = data['submission']  if data['submission']  # "",
              Severity: Minor
              Found in lib/sportradar/api/mma/result.rb - 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

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

                      def get_tournament_id(data, **opts)
                        @tournament_id ||= if opts[:tournament]
                          opts[:tournament].id
                        elsif opts[:season]
                          opts[:season].tournament_id
              Severity: Minor
              Found in lib/sportradar/api/soccer/match.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/soccer/team_group.rb on lines 27..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 45.

              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

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

                      def get_tournament_id(data, **opts)
                        @tournament_id ||= if opts[:tournament]
                          opts[:tournament].id
                        elsif opts[:season]
                          opts[:season].tournament_id
              Severity: Minor
              Found in lib/sportradar/api/soccer/team_group.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/soccer/match.rb on lines 217..229

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

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

                        def update(data, **opts)
              
                          @season = opts[:season] if opts[:season]
              
                          @status   = data['status']                  if data['status']
              Severity: Minor
              Found in lib/sportradar/api/basketball/ncaamb/tournament.rb - 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

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

                      def handle_names(data)
                        # need to do some more work here
                        @name = data['name'] if data['name']
                        if data['name'] && !data.key?('market')
                          @full_name = data['name']
              Severity: Minor
              Found in lib/sportradar/api/football/team.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/basketball/team.rb on lines 52..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 44.

              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 analysis( date = Date.today, content_type: 'all' )
                      raise Sportradar::Api::Error::InvalidType unless allowed_analysis_types.include? content_type
                      response = get request_url("#{provider }/analysis/#{date_path(date)}/#{content_type}")
                      if response.success? && response["items"]
                        Sportradar::Api::Content::ArticleList.new response.to_h
              Severity: Minor
              Found in lib/sportradar/api/content.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/content.rb on lines 13..20

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

              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

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

                      def handle_names(data)
                        # need to do some more work here
                        @name = data['name'] if data['name']
                        if data['name'] && !data.key?('market')
                          @full_name = data['name']
              Severity: Minor
              Found in lib/sportradar/api/basketball/team.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/football/team.rb on lines 55..63

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

              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 news( date = Date.today, content_type: 'all' )
                      raise Sportradar::Api::Error::InvalidType unless allowed_news_types.include? content_type
                      response = get request_url("#{provider }/news/#{date_path(date)}/#{content_type}")
                      if response.success? && response["items"]
                        Sportradar::Api::Content::ArticleList.new response.to_h
              Severity: Minor
              Found in lib/sportradar/api/content.rb and 1 other location - About 55 mins to fix
              lib/sportradar/api/content.rb on lines 23..30

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

              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 get_event_mappings
                        data = api.get_data(path_event_mappings).fetch('mappings', [])
                        if data.size == 1000
                          new_data = data
                          while new_data.size == 1000
              Severity: Minor
              Found in lib/sportradar/api/odds/base.rb and 1 other location - About 45 mins to fix
              lib/sportradar/api/odds/base.rb on lines 45..54

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

              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 get_player_mappings
                        data = api.get_data(path_player_mappings).fetch('mappings', [])
                        if data.size == 1000
                          new_data = data
                          while new_data.size == 1000
              Severity: Minor
              Found in lib/sportradar/api/odds/base.rb and 1 other location - About 45 mins to fix
              lib/sportradar/api/odds/base.rb on lines 33..42

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

              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