um-cseg/chez-betty

View on GitHub

Showing 349 of 349 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    try:
        if 'days' in request.GET:
            num_days = int(request.GET['days'])
        else:
            num_days = 0
Severity: Major
Found in chezbetty/views_data.py and 1 other location - About 4 hrs to fix
chezbetty/views_data.py on lines 274..286

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    try:
        return admin_data_highcharts_period(metric, period)
    except ValueError:
        return {'status': 'error'}
    except utility.InvalidGroupPeriod as e:
Severity: Major
Found in chezbetty/views_data.py and 1 other location - About 4 hrs to fix
chezbetty/views_data.py on lines 248..270

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 78.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function purchase has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

def purchase(user, account, items):
    assert(hasattr(user, "id"))
    assert(len(items) > 0)

    # Give discounts based on user type
Severity: Minor
Found in chezbetty/datalayer.py - About 4 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 _history_mapper has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def _history_mapper(local_mapper):
    cls = local_mapper.class_

    # set the "active_history" flag
    # on on column-mapped attributes so that the old version
Severity: Minor
Found in chezbetty/models/history_meta.py - About 4 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 admin_restock has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def admin_restock(request):
    restock_items = ''
    rows = 0
    global_cost = Decimal(0)
    donation = Decimal(0)
Severity: Minor
Found in chezbetty/views_admin.py - About 4 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

File export_transactions.py has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!./venv/bin/python

# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/commandline.html#writing-a-script
from pyramid.paster import bootstrap

Severity: Minor
Found in export_transactions.py - About 4 hrs to fix

    User has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class User(account.Account):
        __tablename__ = 'users'
        __mapper_args__ = {'polymorphic_identity': 'user'}
    
        id        = Column(Integer, ForeignKey("accounts.id"), primary_key=True)
    Severity: Minor
    Found in chezbetty/models/user.py - About 4 hrs to fix

      Function item_sale_speed has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      def item_sale_speed(num_days, only_item_id=None):
          # TODO: If we're only looking for one item (only_item_id), this can probably
          # be made more efficient
      
          # First we need to figure out when each item was in stock and when it wasn't.
      Severity: Minor
      Found in chezbetty/views_data.py - About 3 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

      File chezbetty-admin.js has 328 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* Functions to manipulate price strings and numbers.
       */
      function format_price (price) {
          p = price.toFixed(2);
      
      
      Severity: Minor
      Found in chezbetty/static/js/chezbetty-admin.js - About 3 hrs to fix

        File user.py has 326 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from pyramid.security import authenticated_userid
        import hashlib
        import binascii
        import os
        from .model import *
        Severity: Minor
        Found in chezbetty/models/user.py - About 3 hrs to fix

          Function admin_user_balance_edit_submit has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          def admin_user_balance_edit_submit(request):
              try:
                  if request.POST['sender-search-choice'] == 'chezbetty':
                      sender = 'chezbetty'
                  else:
          Severity: Minor
          Found in chezbetty/views_admin.py - About 3 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              return DBSession.query(item.Item)\
                      .join(ItemTag)\
                      .join(tag.Tag)\
                      .filter(ItemTag.tag_id == self.id)\
                      .filter(ItemTag.deleted==False)\
          Severity: Major
          Found in chezbetty/models/item_tag.py and 1 other location - About 3 hrs to fix
          chezbetty/models/item_tag.py on lines 59..64

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 71.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              return DBSession.query(item.Item)\
                      .join(ItemTag)\
                      .join(tag.Tag)\
                      .filter(ItemTag.tag_id == self.id)\
                      .filter(ItemTag.deleted==False)\
          Severity: Major
          Found in chezbetty/models/item_tag.py and 1 other location - About 3 hrs to fix
          chezbetty/models/item_tag.py on lines 72..77

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 71.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          @property
          def __subitem_count(self):
              return object_session(self).query(func.count(BoxItem.id).label('c'))\
                      .filter(BoxItem.box_id==self.id)\
                      .filter(BoxItem.enabled).one().c or 0
          Severity: Major
          Found in chezbetty/models/box_item.py and 1 other location - About 3 hrs to fix
          chezbetty/models/box_item.py on lines 38..42

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 70.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          @property
          def __subitem_quantity(self):
              return object_session(self).query(func.sum(BoxItem.quantity).label('c'))\
                      .filter(BoxItem.box_id==self.id)\
                      .filter(BoxItem.enabled).one().c or 0
          Severity: Major
          Found in chezbetty/models/box_item.py and 1 other location - About 3 hrs to fix
          chezbetty/models/box_item.py on lines 45..49

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 70.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function _send_email has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

          def _send_email(msg, FROM):
              settings = get_current_registry().settings
          
              if suppress_emails():
                  print("Mail suppressed due to debug settings")
          Severity: Minor
          Found in chezbetty/utility.py - About 3 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def add_reimbursement(amount, notes, reimbursee, admin, timestamp=None):
              e = event.Reimbursement(admin, notes, timestamp)
              DBSession.add(e)
              DBSession.flush()
              t = transaction.Reimbursement(e, amount, reimbursee)
          Severity: Major
          Found in chezbetty/datalayer.py and 1 other location - About 3 hrs to fix
          chezbetty/datalayer.py on lines 616..622

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def add_withdrawal(amount, notes, reimbursee, admin, timestamp=None):
              e = event.Withdrawal(admin, notes, timestamp)
              DBSession.add(e)
              DBSession.flush()
              t = transaction.Withdrawal(e, amount, reimbursee)
          Severity: Major
          Found in chezbetty/datalayer.py and 1 other location - About 3 hrs to fix
          chezbetty/datalayer.py on lines 626..632

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File utility.py has 303 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from decimal import Decimal
          import itertools
          import qrcode
          import qrcode.image.svg
          import stripe
          Severity: Minor
          Found in chezbetty/utility.py - About 3 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        if transaction_type == 'emptysafe':
                            sheet_banktransfer.write_number(banktransfer_row, 0, t.id)
                            sheet_banktransfer.write_datetime(banktransfer_row, 1, t.event.timestamp.datetime, date_format)
                            sheet_banktransfer.write_number(banktransfer_row, 2, t.amount, money_format)
                            sheet_banktransfer.write(banktransfer_row, 3, "safe")
            Severity: Major
            Found in export_transactions.py and 1 other location - About 3 hrs to fix
            export_transactions.py on lines 114..119

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language