um-cseg/chez-betty

View on GitHub

Showing 349 of 349 total issues

Avoid too many return statements within this function.
Open

                return HTTPFound(location=request.route_url('admin_event', event_id=event.id))
Severity: Major
Found in chezbetty/views_admin.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return HTTPFound(location=request.route_url('admin_events'))
    Severity: Major
    Found in chezbetty/views_admin.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return HTTPFound(location=request.route_url('admin_user_balance_edit'))
      Severity: Major
      Found in chezbetty/views_admin.py - About 30 mins to fix

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

        function alert_error (error_str) {
            html = '<div class="alert alert-danger" role="alert">'+error_str+'</div>';
            alert_clear();
            $("#alerts").html(html);
        }
        Severity: Major
        Found in chezbetty/static/js/chezbetty-user.js and 6 other locations - About 30 mins to fix
        chezbetty/static/js/chezbetty-common.js on lines 10..14
        chezbetty/static/js/chezbetty-common.js on lines 16..20
        chezbetty/static/js/chezbetty-terminal.js on lines 41..45
        chezbetty/static/js/chezbetty-terminal.js on lines 47..51
        chezbetty/static/js/chezbetty-terminal.js on lines 57..61
        chezbetty/static/js/chezbetty-user.js on lines 37..41

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

        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

        Avoid too many return statements within this function.
        Open

                    return HTTPFound(location=request.route_url('admin_events'))
        Severity: Major
        Found in chezbetty/views_admin.py - About 30 mins to fix

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

          function purchase_alert_success (error_str) {
              html = '<div class="alert alert-success" role="alert">'+error_str+'</div>';
              purchase_alert_clear();
              $("#purchase-alerts").html(html);
          }
          Severity: Major
          Found in chezbetty/static/js/chezbetty-terminal.js and 6 other locations - About 30 mins to fix
          chezbetty/static/js/chezbetty-common.js on lines 10..14
          chezbetty/static/js/chezbetty-common.js on lines 16..20
          chezbetty/static/js/chezbetty-terminal.js on lines 41..45
          chezbetty/static/js/chezbetty-terminal.js on lines 47..51
          chezbetty/static/js/chezbetty-user.js on lines 37..41
          chezbetty/static/js/chezbetty-user.js on lines 43..47

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

          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

          Avoid too many return statements within this function.
          Open

                  return HTTPFound(location=request.route_url('admin_reimbursees'))
          Severity: Major
          Found in chezbetty/views_admin.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return HTTPFound(location=request.route_url('admin_user_balance_edit'))
            Severity: Major
            Found in chezbetty/views_admin.py - About 30 mins to fix

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

                      if float(user.balance) < debtor_email_theshold:
                          send_email(
                              TO=user.uniqname+'@umich.edu',
                              SUBJECT='Please Pay Your Chez Betty Balance',
                              body=render('templates/terminal/email_user_in_debt.jinja2',
              Severity: Minor
              Found in chezbetty/views_terminal.py and 2 other locations - About 30 mins to fix
              chezbetty/utility.py on lines 124..128
              chezbetty/utility.py on lines 140..145

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

              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

              Avoid too many return statements within this function.
              Open

                      return HTTPFound(location=request.route_url('admin_cash_reconcile'))
              Severity: Major
              Found in chezbetty/views_admin.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return HTTPFound(location=request.route_url('admin_item_edit', item_id=int(request.POST['item-id'])))
                Severity: Major
                Found in chezbetty/views_admin.py - About 30 mins to fix

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

                  function deposit_alert_error (error_str) {
                      html = '<div class="alert alert-danger" role="alert">'+error_str+'</div>';
                      deposit_alert_clear();
                      $("#deposit-alerts").html(html);
                  }
                  Severity: Major
                  Found in chezbetty/static/js/chezbetty-terminal.js and 6 other locations - About 30 mins to fix
                  chezbetty/static/js/chezbetty-common.js on lines 10..14
                  chezbetty/static/js/chezbetty-common.js on lines 16..20
                  chezbetty/static/js/chezbetty-terminal.js on lines 41..45
                  chezbetty/static/js/chezbetty-terminal.js on lines 57..61
                  chezbetty/static/js/chezbetty-user.js on lines 37..41
                  chezbetty/static/js/chezbetty-user.js on lines 43..47

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

                  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

                      $(this).parent().parent().find(".item-total").html(format_price(quantity*item_price));
                  Severity: Minor
                  Found in chezbetty/static/js/chezbetty-terminal.js and 1 other location - About 30 mins to fix
                  chezbetty/static/js/chezbetty-terminal.js on lines 654..654

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

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

                  function toggle_state_success (data) {
                      var parent = $("#"+$(this).attr("data-parent"))
                  
                      if ($(this).hasClass('require-refresh')) {
                          location.reload();
                  Severity: Minor
                  Found in chezbetty/static/js/chezbetty-user-onload.js - 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 __get_events_by_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def __get_events_by_type(cls, event_type):
                      q = DBSession.query(event.Event)\
                              .join(Transaction)
                  
                      if event_type == 'cash':
                  Severity: Minor
                  Found in chezbetty/models/transaction.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __init__(self, event, user, amount):
                          cashbox_c = account.get_cash_account("cashbox")
                          prev = cashbox_c.balance
                          Transaction.__init__(self, event, None, user, None, cashbox_c, amount)
                          new = cashbox_c.balance
                  Severity: Minor
                  Found in chezbetty/models/transaction.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 admin_user_archive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def admin_user_archive(request):
                      try:
                          user = User.from_id(int(request.matchdict['user_id']))
                  
                          # Cannot archive already archived user
                  Severity: Minor
                  Found in chezbetty/views_admin.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 admin_inventory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def admin_inventory(request):
                      items1 = DBSession.query(Item)\
                                        .filter(Item.enabled==True)\
                                        .filter(Item.in_stock!=0)\
                                        .order_by(Item.name).all()
                  Severity: Minor
                  Found in chezbetty/views_admin.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 toggle_state_success has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function toggle_state_success (data) {
                      var parent = $("#"+$(this).attr("data-parent"));
                  
                      if ($(this).hasClass('require-refresh')) {
                          location.reload();
                  Severity: Minor
                  Found in chezbetty/static/js/chezbetty-admin-onload.js - 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 admin_data_highcharts_period has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def admin_data_highcharts_period(metric, period):
                      start = get_start(0)
                      end = get_end()
                      if metric == 'items':
                          data = PurchaseLineItem.quantity_by_period(period, start=ftz(start), end=ftz(end))
                  Severity: Minor
                  Found in chezbetty/views_data.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