panzarino/mlbgame

View on GitHub

Showing 24 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

      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

      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

        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

        Function __player_stats_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def __player_stats_info(data, name):
            home = []
            away = []
            for y in data:
                # loops through pitchers and batters
        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

        Function standings has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def standings(date):
            DIVISIONS = {
                'AL': {
                    '201': 'AL East',
                    '202': 'AL Central',
        Severity: Minor
        Found in mlbgame/info.py - 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

        Avoid deeply nested control flow statements.
        Open

                            if game:
                                results.append(game)
            return results
        Severity: Major
        Found in mlbgame/__init__.py - About 45 mins to fix

          Function __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, data):
                  """Creates a `GameScoreboard` object.
          
                  data is expected to come from the `scoreboard()` function.
                  """
          Severity: Minor
          Found in mlbgame/game.py - 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

          Function __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, data, inning):
                  """Creates an inning object that matches the corresponding
                  info in `data`.
          
                  `data` should be a dictionary of values.
          Severity: Minor
          Found in mlbgame/events.py - 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

          Consider simplifying this complex logical expression.
          Open

                  if (home_name == home and home is not None) \
                          or (away_name == away and away is not None) \
                          or (away is None and home is None):
                      # throw all the data into a complicated dictionary
                      game_tag = game.tag
          Severity: Major
          Found in mlbgame/game.py - About 40 mins to fix

            Function games has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def games(years, months=None, days=None, home=None, away=None):
            Severity: Minor
            Found in mlbgame/__init__.py - About 35 mins to fix

              Function scoreboard has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def scoreboard(year, month, day, home=None, away=None):
              Severity: Minor
              Found in mlbgame/game.py - About 35 mins to fix

                Function day has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def day(year, month, day, home=None, away=None):
                Severity: Minor
                Found in mlbgame/__init__.py - About 35 mins to fix

                  Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __init__(self, data):
                          """Creates an at bat object that matches the corresponding
                          info in `data`.
                  
                          `data` should be a dictionary of values.
                  Severity: Minor
                  Found in mlbgame/events.py - About 35 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

                  Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __init__(self, data, game_id, player):
                          """Creates a players object that matches the corresponding info in `data`.
                          `data` should be an dictionary of values.
                          'game_id' should be the id for the game.
                          """
                  Severity: Minor
                  Found in mlbgame/stats.py - About 35 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