panzarino/mlbgame

View on GitHub

Showing 45 of 45 total issues

File game.py has 565 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

"""Module that is used for getting basic information about a game
such as the scoreboard and the box score.
"""
Severity: Major
Found in mlbgame/game.py - About 1 day to fix

    File info.py has 434 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    
    """Module that is used for getting information
    about the (MLB) league and the teams in it.
    """
    Severity: Minor
    Found in mlbgame/info.py - About 6 hrs to fix

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

                      try:
                          l_pitcher_data = game.find('l_pitcher')
                          l_pitcher = l_pitcher_data.find('pitcher').attrib['name']
                          l_pitcher_wins = int(l_pitcher_data.attrib['wins'])
                          l_pitcher_losses = int(l_pitcher_data.attrib['losses'])
      Severity: Major
      Found in mlbgame/game.py and 1 other location - About 5 hrs to fix
      mlbgame/game.py on lines 56..64

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

      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

                      try:
                          w_pitcher_data = game.find('w_pitcher')
                          w_pitcher = w_pitcher_data.find('pitcher').attrib['name']
                          w_pitcher_wins = int(w_pitcher_data.attrib['wins'])
                          w_pitcher_losses = int(w_pitcher_data.attrib['losses'])
      Severity: Major
      Found in mlbgame/game.py and 1 other location - About 5 hrs to fix
      mlbgame/game.py on lines 65..73

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

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

      def scoreboard(year, month, day, home=None, away=None):
          """Return the scoreboard information for games matching the parameters
          as a dictionary.
          """
          # get data
      Severity: Minor
      Found in mlbgame/game.py - 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

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

              for pitcher in pitching.findall('pitcher'):
                  stats = {}
                  for i in pitcher.attrib:
                      stats[i] = pitcher.attrib[i]
                  if home_flag:
      Severity: Major
      Found in mlbgame/stats.py and 1 other location - About 3 hrs to fix
      mlbgame/stats.py on lines 49..56

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

      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

              for batter in batting.findall('batter'):
                  stats = {}
                  for i in batter.attrib:
                      stats[i] = batter.attrib[i]
                  if home_flag:
      Severity: Major
      Found in mlbgame/stats.py and 1 other location - About 3 hrs to fix
      mlbgame/stats.py on lines 39..46

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

      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

              for p in team.findall('player'):
                  player = {}
                  for key in p.keys():
                      player[key] = p.get(key)
                  output[type]['players'].append(player)
      Severity: Major
      Found in mlbgame/game.py and 1 other location - About 3 hrs to fix
      mlbgame/game.py on lines 574..578

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

      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

              for c in team.findall('coach'):
                  coach = {}
                  for key in c.keys():
                      coach[key] = c.get(key)
                  output[type]['coaches'].append(coach)
      Severity: Major
      Found in mlbgame/game.py and 1 other location - About 3 hrs to fix
      mlbgame/game.py on lines 568..572

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

      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

      File stats.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
      
      """Module that controls getting stats and creating objects to hold that
      information."""
      
      
      Severity: Minor
      Found in mlbgame/stats.py - About 2 hrs to fix

        Function games has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        def games(years, months=None, days=None, home=None, away=None):
            """Return a list of lists of games for multiple days.
        
            If home and away are the same team, it will return all games for that team.
            """
        Severity: Minor
        Found in mlbgame/__init__.py - 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

        Function __raw_player_stats_info has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def __raw_player_stats_info(data):
            home_pitchers = []
            away_pitchers = []
            home_batters = []
            away_batters = []
        Severity: Minor
        Found in mlbgame/stats.py - 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

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

        def get_game_events(game_id):
            """Return the game events file of a game with matching id."""
            year, month, day = get_date_from_game_id(game_id)
            try:
                return urlopen(GAME_URL.format(year, month, day, game_id,
        Severity: Major
        Found in mlbgame/data.py and 4 other locations - About 2 hrs to fix
        mlbgame/data.py on lines 65..72
        mlbgame/data.py on lines 75..82
        mlbgame/data.py on lines 104..111
        mlbgame/data.py on lines 114..121

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

        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

        def get_players(game_id):
            """Return the players file of a game with matching id."""
            year, month, day = get_date_from_game_id(game_id)
            try:
                return urlopen(GAME_URL.format(year, month, day, game_id,
        Severity: Major
        Found in mlbgame/data.py and 4 other locations - About 2 hrs to fix
        mlbgame/data.py on lines 65..72
        mlbgame/data.py on lines 75..82
        mlbgame/data.py on lines 85..92
        mlbgame/data.py on lines 104..111

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

        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

        def get_raw_box_score(game_id):
            """Return the raw box score file of a game with matching id."""
            year, month, day = get_date_from_game_id(game_id)
            try:
                return urlopen(GAME_URL.format(year, month, day, game_id,
        Severity: Major
        Found in mlbgame/data.py and 4 other locations - About 2 hrs to fix
        mlbgame/data.py on lines 65..72
        mlbgame/data.py on lines 85..92
        mlbgame/data.py on lines 104..111
        mlbgame/data.py on lines 114..121

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

        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

        def get_overview(game_id):
            """Return the linescore file of a game with matching id."""
            year, month, day = get_date_from_game_id(game_id)
            try:
                return urlopen(GAME_URL.format(year, month, day, game_id,
        Severity: Major
        Found in mlbgame/data.py and 4 other locations - About 2 hrs to fix
        mlbgame/data.py on lines 65..72
        mlbgame/data.py on lines 75..82
        mlbgame/data.py on lines 85..92
        mlbgame/data.py on lines 114..121

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

        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

        def get_box_score(game_id):
            """Return the box score file of a game with matching id."""
            year, month, day = get_date_from_game_id(game_id)
            try:
                return urlopen(GAME_URL.format(year, month, day, game_id,
        Severity: Major
        Found in mlbgame/data.py and 4 other locations - About 2 hrs to fix
        mlbgame/data.py on lines 75..82
        mlbgame/data.py on lines 85..92
        mlbgame/data.py on lines 104..111
        mlbgame/data.py on lines 114..121

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

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

        def players(game_id):
            """Gets player/coach/umpire information for the game with matching id."""
            # get data
            data = mlbgame.data.get_players(game_id)
            # parse data
        Severity: Minor
        Found in mlbgame/game.py - 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

        Function __inning_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def __inning_info(inning, part, endpoint):
            # info
            info = []
            # loop through the half
            # Added more robust exception handling to catch final innings'
        Severity: Minor
        Found in mlbgame/events.py - 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

        Function __raw_team_stats_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def __raw_team_stats_info(data, output):
            for team in data.findall('team'):
                home_flag = team.attrib['team_flag'] == 'home'
                pitching = team.find('pitching')
                stats = {}
        Severity: Minor
        Found in mlbgame/stats.py - 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

        Severity
        Category
        Status
        Source
        Language