beneggett/sportradar-api

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

Summary

Maintainability
C
1 day
Test Coverage

Method pitch_outcomes has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def self.pitch_outcomes
          @pitch_outcomes ||= {
            'aBK'     => 'Balk',
            'aCI'     => 'Catcher Interference',
            'aD'      => 'Double',
Severity: Major
Found in lib/sportradar/api/baseball/pitch.rb - About 3 hrs to fix

    Class Pitch has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class Pitch < Data
            attr_accessor :response, :id, :at_bat, :outcome_id, :status, :count, :is_ab_over, :is_hit, :warming_up, :runners, :errors, :pitch_type_name, :x, :y, :zone, :total_pitch_count, :atbat_pitch_count, :speed, :outcome, :hit_type, :balls, :strikes, :outs, :fielders
    
            def initialize(data, **opts)
              @response = data
    Severity: Minor
    Found in lib/sportradar/api/baseball/pitch.rb - About 2 hrs to fix

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

              def update(data, **opts)
      
                if data['outcome_id']
                  @outcome_id   = data['outcome_id']
                  @outcome      = self.class.pitch_outcome(@outcome_id)
      Severity: Minor
      Found in lib/sportradar/api/baseball/pitch.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 parse_flags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def parse_flags(data)
                @is_ab_over     = data['is_ab_over']       if data['is_ab_over']
                @is_bunt        = data['is_bunt']          if data['is_bunt']
                @is_bunt_shown  = data['is_bunt_shown']    if data['is_bunt_shown']
                @is_hit         = data['is_hit']           if data['is_hit']
      Severity: Minor
      Found in lib/sportradar/api/baseball/pitch.rb - 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

      Method parse_pitcher has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def parse_pitcher(data)
                @type         = data['pitch_type']   if data['pitch_type']
                @speed        = data['pitch_speed']  if data['pitch_speed']
                @x            = data['pitch_x']      if data['pitch_x']
                @y            = data['pitch_y']      if data['pitch_y']
      Severity: Minor
      Found in lib/sportradar/api/baseball/pitch.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 3 locations. Consider refactoring.
      Open

              {"type"=>"steal", "id"=>"37c9192d-cac9-4320-b721-f68955eecf24", "status"=>"official", "created_at"=>"2017-05-06T03:02:16+00:00", "pitcher"=>{"id"=>"90fb6719-5135-42f3-88c0-0ccde448368c"}, "runners"=>[{"id"=>"106e6fb6-6460-412e-abdb-9f73469a27b9", "starting_base"=>1, "ending_base"=>1, "outcome_id"=>"CK", "out"=>false, "last_name"=>"DeShields", "first_name"=>"Delino", "preferred_name"=>"Delino", "jersey_number"=>"3"}]}
      Severity: Minor
      Found in lib/sportradar/api/baseball/pitch.rb and 2 other locations - About 35 mins to fix
      lib/sportradar/api/baseball/pitch.rb on lines 130..130
      lib/sportradar/api/baseball/pitch.rb on lines 132..132

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

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

              {"type"=>"steal", "id"=>"76762fd9-683c-42f2-8c72-8d9fd4f5bc7b", "status"=>"official", "created_at"=>"2017-05-06T02:56:49+00:00", "pitcher"=>{"id"=>"9dd06397-4353-44e8-81bb-6e88a75e42b5"}, "runners"=>[{"id"=>"3e39fe20-6dca-4894-807b-1ce76ff93e29", "starting_base"=>1, "ending_base"=>1, "outcome_id"=>"", "out"=>false, "last_name"=>"Owings", "first_name"=>"Christopher", "preferred_name"=>"Chris", "jersey_number"=>"16"}]}
      Severity: Minor
      Found in lib/sportradar/api/baseball/pitch.rb and 2 other locations - About 35 mins to fix
      lib/sportradar/api/baseball/pitch.rb on lines 132..132
      lib/sportradar/api/baseball/pitch.rb on lines 133..133

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

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

              {"type"=>"steal", "id"=>"df01b116-afcd-467f-9b9c-99d3891629c6", "status"=>"official", "created_at"=>"2017-05-06T03:00:58+00:00", "pitcher"=>{"id"=>"90fb6719-5135-42f3-88c0-0ccde448368c"}, "runners"=>[{"id"=>"106e6fb6-6460-412e-abdb-9f73469a27b9", "starting_base"=>1, "ending_base"=>1, "outcome_id"=>"CK", "out"=>false, "last_name"=>"DeShields", "first_name"=>"Delino", "preferred_name"=>"Delino", "jersey_number"=>"3"}]}
      Severity: Minor
      Found in lib/sportradar/api/baseball/pitch.rb and 2 other locations - About 35 mins to fix
      lib/sportradar/api/baseball/pitch.rb on lines 130..130
      lib/sportradar/api/baseball/pitch.rb on lines 133..133

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

      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