Showing 36 of 36 total issues
Function parse_metadata
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_metadata(html):
"""Return document metadata from Open Graph, meta, and title tags.
If title Open Graph property is not set, uses the document title tag. If the description Open Graph property is
not set, uses the description meta tag.
- 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 invite_members
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def invite_members(request, team_id):
"""Return a team edit view, or handle the form submission."""
team = get_object_or_404(Team, pk=team_id)
if team.owner_id is None or team.owner_id != request.user.id:
- 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 send_digest_emails
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def send_digest_emails(digest_frequency):
"""Send daily digests to users subscribed to digests with frequency digest_frequency.
:return tuple containing number of emails successfully sent and number that failed to send
"""
- 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 clean
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def clean(self):
"""Validate the BoardPermissions model.
Check that the read permission is valid with respect to the relative to the global ACCOUNT_REQUIRED setting.
Check that the other permissions are valid relative to
- 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
Consider simplifying this complex logical expression. Open
if non_na and user.value < 3 and aggregate.value < 3:
return "eval-inconsistent"
elif non_na and user.value > 3 and aggregate.value > 3:
return "eval-consistent"
elif user.value == 0 or aggregate.value == 0:
Function join_team
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def join_team(request, team_id):
team = get_object_or_404(Team, pk=team_id)
if team.members.filter(id=request.user.id).exists():
raise SuspiciousOperation(_("User is already a member of the team"))
- 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 notification_digest
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def notification_digest(user, start, end):
"""Return digest for user with content/notifications occurring after start.
Notifications are grouped by target, e.g., board.
- 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 create_board
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_board(request):
"""Return a board creation view, or handle the form submission.
Set default permissions for the new board. Mark board creator as a board follower.
"""
- 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 "disagree-mild-dispute"
Avoid too many return
statements within this function. Open
return "disagree-large-dispute"
Avoid too many return
statements within this function. Open
return "disagree-consensus"
Function edit_team
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def edit_team(request, team_id):
"""Return a team edit view, or handle the form submission."""
# TODO: if user turns off invitation-required, let everyone in who had outstanding membership requests
team = get_object_or_404(Team, pk=team_id)
- 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 add_source
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_source(request, evidence_id):
"""Return a view for adding a corroborating/contradicting source, or handle form submission."""
evidence = get_object_or_404(Evidence, pk=evidence_id)
if request.method == "POST":
form = EvidenceSourceForm(request.POST)
- 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 calc_disagreement
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def calc_disagreement(evaluations):
"""Return the disagreement level for evaluations, or None if no evaluations.
Calculated as the max disagreement of (1) N/A and non-N/A responses and (2) non-N/A evaluations
:param evaluations: an iterable of Eval
- 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
Do not use bare 'except' Open
except: # pylint: disable=bare-except
- Read upRead up
- Exclude checks
When catching exceptions, mention specific exceptions when possible.
Okay: except Exception:
Okay: except BaseException:
E722: except:
Whitespace before ':' Open
metadata[tag["property"][len("og:") :]] = tag["content"].strip()
- Read upRead up
- Exclude checks
Avoid extraneous whitespace.
Avoid extraneous whitespace in these situations:
- Immediately inside parentheses, brackets or braces.
- Immediately before a comma, semicolon, or colon.
Okay: spam(ham[1], {eggs: 2})
E201: spam( ham[1], {eggs: 2})
E201: spam(ham[ 1], {eggs: 2})
E201: spam(ham[1], { eggs: 2})
E202: spam(ham[1], {eggs: 2} )
E202: spam(ham[1 ], {eggs: 2})
E202: spam(ham[1], {eggs: 2 })
E203: if x == 4: print x, y; x, y = y , x
E203: if x == 4: print x, y ; x, y = y, x
E203: if x == 4 : print x, y; x, y = y, x