File parsing.py
has 738 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
Provides utilities for parsing responses from
Rising Storm 2: Vietnam WebAdmin.
TODO: This module is growing fast. Needs refactoring.
Function parse_current_game
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_current_game(self, resp: bytes) -> models.CurrentGame:
"""TODO: headers vs. rows length assertion!"""
parsed_html = self.parse_html(resp)
info = {}
RS2WebAdminResponseParser
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class RS2WebAdminResponseParser:
# TODO: Refactor magic numbers.
def __init__(self, encoding: str = None):
if not encoding:
Function parse_current_game
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def parse_current_game(self, resp: bytes) -> models.CurrentGame:
"""TODO: headers vs. rows length assertion!"""
parsed_html = self.parse_html(resp)
info = {}
- Read upRead up
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 parse_session_bans
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def parse_session_bans(self, resp: bytes,
adapter: adapters.WebAdminAdapter
) -> List[adapters.SessionBanWrapper]:
parsed_html = self.parse_html(resp)
- Read upRead up
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 parse_bans
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def parse_bans(self, resp: bytes,
adapter: adapters.WebAdminAdapter
) -> List[adapters.BanWrapper]:
parsed_html = self.parse_html(resp)
- Read upRead up
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 parse_players
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def parse_players(self, resp: bytes, adapter: adapters.WebAdminAdapter
) -> List[adapters.PlayerWrapper]:
parsed_html = self.parse_html(resp)
if not parsed_html:
logger.error(
- Read upRead up
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 parse_members
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_members(self, resp: bytes,
adapter: adapters.WebAdminAdapter
) -> List[adapters.MemberWrapper]:
parsed_html = self.parse_html(resp)
members_table = parsed_html.find("table", attrs={"id": "members"})
- Read upRead up
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 parse_tracking
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_tracking(self, resp: bytes,
adapter: adapters.WebAdminAdapter
) -> List[adapters.TrackingWrapper]:
parsed_html = self.parse_html(resp)
- Read upRead up
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 parse_chat_message
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse_chat_message(div: BeautifulSoup) -> models.ChatMessage:
teamcolor = str(div.find(
"span", attrs={"class": "teamcolor"}).get("style"))
if not teamcolor:
logger.error(
- Read upRead up
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 parse_squads
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_squads(self, resp: bytes,
adapter: adapters.WebAdminAdapter
) -> List[adapters.SquadWrapper]:
parsed_html = self.parse_html(resp)
parsed_html = parsed_html.find("table", attrs={"id": "squads"})
- Read upRead up
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 too many return
statements within this function. Open
return players
Function parse_player_id_key
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_player_id_key(
self, resp: bytes,
player: Union[models.Player, adapters.PlayerWrapper]
) -> Tuple[int, str]:
"""Parse "hidden" player key and ID from players table."""
- Read upRead up
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"