twschiller/open-synthesis

View on GitHub

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.
Severity: Minor
Found in openach/tasks.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 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:
Severity: Minor
Found in openach/views/teams.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 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
    """
Severity: Minor
Found in openach/digest.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 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
Severity: Minor
Found in openach/models.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 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:
Severity: Major
Found in openach/templatetags/board_extras.py - About 40 mins to fix

    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"))
    Severity: Minor
    Found in openach/views/teams.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 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.
    
    
    Severity: Minor
    Found in openach/digest.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 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.
        """
    Severity: Minor
    Found in openach/views/boards.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

    Avoid too many return statements within this function.
    Open

            return "disagree-mild-dispute"
    Severity: Major
    Found in openach/templatetags/board_extras.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return "disagree-large-dispute"
      Severity: Major
      Found in openach/templatetags/board_extras.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return "disagree-consensus"
        Severity: Major
        Found in openach/templatetags/board_extras.py - About 30 mins to fix

          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)
          Severity: Minor
          Found in openach/views/teams.py - About 25 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 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)
          Severity: Minor
          Found in openach/views/evidence.py - About 25 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 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
          Severity: Minor
          Found in openach/metrics.py - About 25 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

          Do not use bare 'except'
          Open

                  except:  # pylint: disable=bare-except
          Severity: Minor
          Found in openintel/settings.py by pep8

          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()
          Severity: Minor
          Found in openach/tasks.py by pep8

          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
          Severity
          Category
          Status
          Source
          Language