config/scripts/create_users.py

Summary

Maintainability
A
2 hrs
Test Coverage

Function generate_names has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def generate_names(args: argparse.Namespace) -> "list[tuple[str]]":
    for i, name in enumerate(args.names):
        username = ""
        if not args.noyear and args.type != "teacher":
            username = grade_to_year(args.year if args.year else random.choice(GRADES))
Severity: Minor
Found in config/scripts/create_users.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 create_admins has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def create_admins(args: argparse.Namespace) -> None:
    group = Group.objects.get_or_create(name="admin_all")[0]
    for first_name, last_name, username in args.names:
        username = validate(username)
        user = User.objects.get_or_create(first_name=first_name, last_name=last_name, username=username)[0]
Severity: Minor
Found in config/scripts/create_users.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_students has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def create_students(args: argparse.Namespace) -> None:
    for first_name, last_name, username in args.names:
        username = validate(username)
        user = User.objects.get_or_create(first_name=first_name, last_name=last_name, username=username)[0]
        if not args.noyear:
Severity: Minor
Found in config/scripts/create_users.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

Line too long (147 > 79 characters)
Open

        "-n", "--names", nargs="+", default=[], help="Provide in format first_last, or as a username, ignores count if supplied, seperate with '_'"
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (145 > 79 characters)
Open

    parser.add_argument("-g", "--gender", type=str, required=False, choices=["male", "female"], help="Gender of user's name, defaults to either")
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (121 > 79 characters)
Open

    parser.add_argument("-nw", "--nowelcome", action="store_true", help="disables welcome message on first login to ion")
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (128 > 79 characters)
Open

        user = User.objects.get_or_create(first_name=first_name, last_name=last_name, username=username, user_type="teacher")[0]
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (107 > 79 characters)
Open

        user = User.objects.get_or_create(first_name=first_name, last_name=last_name, username=username)[0]
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (86 > 79 characters)
Open

            first_name, last_name = names.get_full_name(gender=args.gender).split(" ")
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (87 > 79 characters)
Open

            username = grade_to_year(args.year if args.year else random.choice(GRADES))
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (107 > 79 characters)
Open

        user = User.objects.get_or_create(first_name=first_name, last_name=last_name, username=username)[0]
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (126 > 79 characters)
Open

    parser.add_argument("-ny", "--noyear", action="store_true", help="does not prepend username with year, ignores year flag")
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (94 > 79 characters)
Open

    parser.add_argument("-v", "--verbose", action="store_true", help="Enables verbose output")
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (142 > 79 characters)
Open

        "-y", "--year", type=str, required=False, choices=GRADES, help="Year of student, doesn't do anything for teachers, defaults to random"
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (110 > 79 characters)
Open

    parser.add_argument("-c", "--count", type=int, default=10, help="Number of users to make, defaults to 10")
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Line too long (134 > 79 characters)
Open

    parser.add_argument("-t", "--type", type=str, required=True, choices=["student", "teacher", "admin"], help="type of user to make")
Severity: Minor
Found in config/scripts/create_users.py by pep8

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

There are no issues that match your filters.

Category
Status