sweh/sw.allotmentclub.backend

View on GitHub

Showing 48 of 49 total issues

Function login has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
Open

    def login(self):
        if self.request.params.get('to'):
            # timeout occured, redirected from a javascript json request
            self.request.session.flash(SESSION_TIMEOUT, 'error')

Severity: Minor
Found in src/sw/allotmentclub/browser/login.py - About 2 hrs 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 export_members_vcf has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
Open

def export_members_vcf():
    parser = gocept.logging.ArgumentParser(
        description="Export members in vcf format.")
    parser.add_argument('-c', '--config', default='portal.ini',
                        help='Specify the config file. (default: portal.ini)')
Severity: Minor
Found in src/sw/allotmentclub/scripts.py - About 2 hrs 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 update has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
Open

    def update(self):
        if self.recipients == [None]:
            return
        recipients = []
        if not self.context.sent:
Severity: Minor
Found in src/sw/allotmentclub/browser/mail.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 add_transaction has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
Open

def add_transaction(data, account):
    from sw.allotmentclub import Member
    accounting_year = data['date'].year
    org_title = None
    org = Organization.get(account.organization_id)
Severity: Minor
Found in src/sw/allotmentclub/account.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 update has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
Open

    def update(self):
        data = []
        items = []  # id, text, parent, state, icon
        for text, id, icon, children in NAVIGATION_ITEMS:
            parent = '#'
Severity: Minor
Found in src/sw/allotmentclub/browser/authority.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 get_membership_fees has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
Open

def get_membership_fees(year=None, currency_formatter=None):
    if year is None:
        year = get_selected_year()
    members = {}
    for parcel in Parcel.query().all():
Severity: Minor
Found in src/sw/allotmentclub/browser/member.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 update has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def update(self):
        output = PdfFileWriter()
        if self.recipients == [None] or self.preview:
            recipients = self.recipients
        else:
Severity: Minor
Found in src/sw/allotmentclub/browser/mail.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 __call__ has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def __call__(self):
        result = []
        for title, route, css, sublinks in NAVIGATION_ITEMS:
            if not route_permitted(route, self.request):
                continue
Severity: Minor
Found in src/sw/allotmentclub/browser/navigation.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 __call__ has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def __call__(self):
        result = super(HomeView, self).__call__()
        last = None
        timeline = []
        for date, user_id, type_, msg in sw.allotmentclub.json_result(
Severity: Minor
Found in src/sw/allotmentclub/browser/home.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 get_form_attributes has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

    def get_form_attributes(self):
        form_attributes = []
        for item in self.form_attributes:
            form_attributes.append(item.copy())
        for item in form_attributes:
Severity: Minor
Found in src/sw/allotmentclub/browser/base.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 moneyfmt has 9 arguments (exceeds 8 allowed). Consider refactoring.
Open

def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-',
Severity: Major
Found in src/sw/allotmentclub/browser/base.py - About 35 mins to fix

    Function render_pdf has 9 arguments (exceeds 8 allowed). Consider refactoring.
    Open

    def render_pdf(
    Severity: Major
    Found in src/sw/allotmentclub/browser/letter.py - About 35 mins to fix

      Function write_cell has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

          def write_cell(self, row, column, cell):
              style = {}
              value = cell
      
              if isinstance(cell, tuple):
      Severity: Minor
      Found in src/sw/allotmentclub/browser/base.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 moneyfmt has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

      def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-',
                   trailneg='', request=None):
          """Convert Decimal to a money formatted string.
      
          see: http://docs.python.org/2/library/decimal.html#recipes
      Severity: Minor
      Found in src/sw/allotmentclub/browser/base.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 export_events_ics has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

      def export_events_ics():
          import sw.allotmentclub.browser.calendar
          parser = gocept.logging.ArgumentParser(
              description="Export events in ics format.")
          parser.add_argument('-c', '--config', default='portal.ini',
      Severity: Minor
      Found in src/sw/allotmentclub/scripts.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 __call__ has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

          def __call__(self):
              incoming = get_incoming_raw(self.context.id, self.request)
              columns = [
                  {'name': name, 'css_class': 'hide' if id == 0 else ''}
                  for id, name in enumerate(
      Severity: Minor
      Found in src/sw/allotmentclub/browser/account.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 update has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

          def update(self):
              try:
                  json = self.request.json
              except ValueError:
                  json = None
      Severity: Minor
      Found in src/sw/allotmentclub/browser/base.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

      Possible SQL injection vector through string-based query construction.
      Open

      """.format(pw='$2b$12$i8SjfxgMnw464DAyFJEipeXswIvtC.OcrSGYYZ/PBAC97NvJus0ou'))

      Use of insecure MD2, MD4, MD5, or SHA1 hash function.
      Open

                                  hashlib.md5(
                                      user.email.encode('utf-8')).hexdigest()))
      Severity: Minor
      Found in src/sw/allotmentclub/browser/home.py by bandit

      Use of exec detected.
      Open

      exec(open("src/sw/allotmentclub/version.py").read())
      Severity: Minor
      Found in setup.py by bandit
      Severity
      Category
      Status
      Source
      Language