um-cseg/chez-betty

View on GitHub

Showing 349 of 349 total issues

File views_admin.py has 2793 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from pyramid.events import subscriber
from pyramid.events import BeforeRender
from pyramid.httpexceptions import HTTPFound
from pyramid.renderers import render
from pyramid.renderers import render_to_response
Severity: Major
Found in chezbetty/views_admin.py - About 1 wk to fix

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

    Severity: Major
    Found in chezbetty/models/item_vendor.py and 1 other location - About 3 days to fix
    chezbetty/models/box_vendor.py on lines 0..52

    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 360.

    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

    Severity: Major
    Found in chezbetty/models/box_vendor.py and 1 other location - About 3 days to fix
    chezbetty/models/item_vendor.py on lines 0..51

    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 360.

    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 transaction.py has 851 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from .model import *
    from . import account
    from . import event
    from . import item
    from . import box
    Severity: Major
    Found in chezbetty/models/transaction.py - About 2 days to fix

      Function admin_items_list has a Cognitive Complexity of 98 (exceeds 5 allowed). Consider refactoring.
      Open

      def admin_items_list(request):
          group = request.GET['group'] if 'group' in request.GET else 'active'
      
          if group == 'active':
              page  = 'active'
      Severity: Minor
      Found in chezbetty/views_admin.py - About 1 day 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_submit has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
      Open

      def admin_restock_submit(request):
      
          # Array of (Item, quantity, total) tuples
          items_for_pricing = []
          # Keep track of the total number of items being restocked. We use
      Severity: Minor
      Found in chezbetty/views_admin.py - About 1 day 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_box_edit_submit has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
      Open

      def admin_box_edit_submit(request):
          try:
              box = Box.from_id(int(request.POST['box-id']))
      
              if not box.exists_barcode(request.POST['box-barcode'], box.id):
      Severity: Minor
      Found in chezbetty/views_admin.py - About 1 day 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

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

      @view_config(route_name='user_item_list',
                   renderer='templates/user/item_list.jinja2',
                   permission='user')
      def item_list(request):
          items = DBSession.query(Item)\
      Severity: Major
      Found in chezbetty/views_user.py and 1 other location - About 1 day to fix
      chezbetty/views_public.py on lines 36..51

      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 151.

      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

      @view_config(route_name='items', renderer='templates/public/items.jinja2')
      def items(request):
          items = DBSession.query(Item)\
                           .filter(Item.enabled==True)\
                           .filter(Item.in_stock>0)\
      Severity: Major
      Found in chezbetty/views_public.py and 1 other location - About 1 day to fix
      chezbetty/views_user.py on lines 242..259

      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 151.

      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 chezbetty-terminal.js has 564 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
       * Chez Betty Main Terminal Javascript
       *
       */
      
      
      Severity: Major
      Found in chezbetty/static/js/chezbetty-terminal.js - About 1 day to fix

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

            @classmethod #search for all delimited barcodes in database; return true if any matches are found
            def exists_barcode(cls, barcode, id=None):
                #split string into individual barcodes
                barcode_list = barcode.split(';')
                for single_barcode in barcode_list:
        Severity: Major
        Found in chezbetty/models/box.py and 1 other location - About 1 day to fix
        chezbetty/models/item.py on lines 105..120

        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 129.

        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

            @classmethod #check to see if the barcode(s) exist in *other* items (not the current one being updated)
            def exists_barcode(cls, barcode, id=None):
                #split string into individual barcodes
                barcode_list = barcode.split(';')
                for single_barcode in barcode_list:
        Severity: Major
        Found in chezbetty/models/item.py and 1 other location - About 1 day to fix
        chezbetty/models/box.py on lines 76..91

        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 129.

        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 admin_item_edit has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_item_edit(request):
            try:
                try:
                    purchase_limit = request.GET['purchase_limit']
                    if purchase_limit.lower() == 'none':
        Severity: Minor
        Found in chezbetty/views_admin.py - About 1 day 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_item_edit_submit has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_item_edit_submit(request):
            try:
                item = Item.from_id(int(request.POST['item-id']))
        
                for key in request.POST:
        Severity: Minor
        Found in chezbetty/views_admin.py - About 7 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_box_add_submit has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_box_add_submit(request):
            try:
                error = False
                items_empty_barcode = 0
        
        
        Severity: Minor
        Found in chezbetty/views_admin.py - About 7 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 views_data.py has 478 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from pyramid.events import subscriber
        from pyramid.events import BeforeRender
        from pyramid.httpexceptions import HTTPFound
        from pyramid.renderers import render
        from pyramid.renderers import render_to_response
        Severity: Minor
        Found in chezbetty/views_data.py - About 7 hrs to fix

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

          def delete_item(item):
              boxitems = DBSession.query(box_item.BoxItem).filter(box_item.BoxItem.item_id==item.id).all()
              for bi in boxitems:
                  DBSession.delete(bi)
              itemvendors = DBSession.query(item_vendor.ItemVendor).filter(item_vendor.ItemVendor.item_id==item.id).all()
          Severity: Major
          Found in chezbetty/datalayer.py and 1 other location - About 7 hrs to fix
          chezbetty/datalayer.py on lines 176..183

          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 115.

          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 delete_box(box):
              boxitems = DBSession.query(box_item.BoxItem).filter(box_item.BoxItem.box_id==box.id).all()
              for bi in boxitems:
                  DBSession.delete(bi)
              boxvendors = DBSession.query(box_vendor.BoxVendor).filter(box_vendor.BoxVendor.box_id==box.id).all()
          Severity: Major
          Found in chezbetty/datalayer.py and 1 other location - About 7 hrs to fix
          chezbetty/datalayer.py on lines 160..167

          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 115.

          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 main has 176 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def main(global_config, **settings):
              engine = engine_from_config(settings, 'sqlalchemy.')
              Base.metadata.create_all(engine)
              DBSession.configure(bind=engine)
          
          
          Severity: Major
          Found in chezbetty/__init__.py - About 7 hrs to fix

            Function iterate_recent_items has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
            Open

                def iterate_recent_items(self, limit=None, allow_duplicates=False, pictures_only=True):
                    cap_search = 20
                    items = set()
                    count = 0
                    for e in self.events:
            Severity: Minor
            Found in chezbetty/models/user.py - About 6 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

            Severity
            Category
            Status
            Source
            Language