muneebalam/scrapenhl2

View on GitHub
scrapenhl2/scrape/players.py

Summary

Maintainability
F
3 days
Test Coverage

File players.py has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
This module contains methods related to individual player info.
"""

import functools
Severity: Minor
Found in scrapenhl2/scrape/players.py - About 6 hrs to fix

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

    def player_as_id(playername, filterids=None, dob=None):
        """
        A helper method. If player entered is int, returns that. If player is str, returns integer id of that player.
    
        :param playername: int, or str, the player whose names you want to retrieve
    Severity: Minor
    Found in scrapenhl2/scrape/players.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 player_as_str has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def player_as_str(playerid, filterids=None):
        """
        A helper method. If player is int, returns string name of that player. Else returns standardized name.
    
        :param playerid: int, or str, player whose name you want to retrieve
    Severity: Minor
    Found in scrapenhl2/scrape/players.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 update_player_log_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_player_log_file(playerids, seasons, games, teams, statuses):
        """
        Updates the player log file with given players. The player log file notes which players played in which games
        and whether they were scratched or played.
    
    
    Severity: Minor
    Found in scrapenhl2/scrape/players.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 update_player_log_file has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def update_player_log_file(playerids, seasons, games, teams, statuses):
    Severity: Minor
    Found in scrapenhl2/scrape/players.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

              return None
      Severity: Major
      Found in scrapenhl2/scrape/players.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return df.ID.iloc[0]
        Severity: Major
        Found in scrapenhl2/scrape/players.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return None
          Severity: Major
          Found in scrapenhl2/scrape/players.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return default
            Severity: Major
            Found in scrapenhl2/scrape/players.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return df.ID.iloc[0]
              Severity: Major
              Found in scrapenhl2/scrape/players.py - About 30 mins to fix

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

                @functools.lru_cache(maxsize=128, typed=False)
                def get_player_handedness(player):
                    """
                    Retrieves handedness of player
                
                
                Severity: Major
                Found in scrapenhl2/scrape/players.py and 1 other location - About 5 hrs to fix
                scrapenhl2/scrape/players.py on lines 251..267

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

                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

                @functools.lru_cache(maxsize=128, typed=False)
                def get_player_position(player):
                    """
                    Retrieves position of player
                
                
                Severity: Major
                Found in scrapenhl2/scrape/players.py and 1 other location - About 5 hrs to fix
                scrapenhl2/scrape/players.py on lines 270..286

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

                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

                        if len(df) == 0:
                            print('Could not find name for {0:.0f}'.format(playerid))
                            return None
                        elif len(df) == 1:
                            return df.Name.iloc[0]
                Severity: Major
                Found in scrapenhl2/scrape/players.py and 1 other location - About 4 hrs to fix
                scrapenhl2/scrape/team_info.py on lines 192..200

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

                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

                    if filterids is None:
                        pass
                    else:
                        filterdf = filterdf.merge(pd.DataFrame({'ID': filterids}), how='inner', on='ID')
                Severity: Major
                Found in scrapenhl2/scrape/players.py and 1 other location - About 1 hr to fix
                scrapenhl2/scrape/players.py on lines 401..404

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

                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

                    if filterids is None:
                        pass
                    else:
                        filterdf = filterdf.merge(pd.DataFrame({'ID': filterids}), how='inner', on='ID')
                Severity: Major
                Found in scrapenhl2/scrape/players.py and 1 other location - About 1 hr to fix
                scrapenhl2/scrape/players.py on lines 301..304

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

                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