redditraffler/redditraffler

View on GitHub

Showing 6 of 13 total issues

Function register_webpack_context_processor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def register_webpack_context_processor(app):
    """Adds the import_webpack_entrypoint utility function in Jinja templates
    """

    def import_webpack_entrypoint(entrypoint: str) -> List[str]:
Severity: Minor
Found in app/factory.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 _validate_int_values has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_int_values(self):
        """ Check if all integer keys have proper values. """
        for key, val in self.form.items():
            if key not in self.INT_KEYS:
                continue
Severity: Minor
Found in app/util/raffle_form_validator.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

Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in app/util/raffler.py - About 50 mins to fix

    Function _validate_ignored_users_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _validate_ignored_users_list(self):
            """ Check that ignoredUsers is a list, and all of its contents
            are valid Reddit usernames. """
            try:
                users_list = json.loads(self.form.get("ignoredUsers"))
    Severity: Minor
    Found in app/util/raffle_form_validator.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 _has_duplicate_comments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _has_duplicate_comments(self, user):
            """ Returns if the user has more than one root comment in the raffle's
            submission. If there is more than one then the user is added to
            the disqualified users set.
            """
    Severity: Minor
    Found in app/util/raffler.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 select_winners has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def select_winners(self):
            """ Loop over the internal set of entries to find comments whose
            author meets the criteria set. Authors that meet the criteria are
            added to an internal dict `_winners`. Returns whether the loop
            succeeded in finding enough winners to match `winner_count`.
    Severity: Minor
    Found in app/util/raffler.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

    Severity
    Category
    Status
    Source
    Language