um-cseg/chez-betty

View on GitHub
chezbetty/models/item.py

Summary

Maintainability
F
3 days
Test Coverage

Function exists_barcode has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def exists_barcode(cls, barcode, id=None):
        #split string into individual barcodes
        barcode_list = barcode.split(';')
        for single_barcode in barcode_list:
            if single_barcode != "":
Severity: Minor
Found in chezbetty/models/item.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, name, barcode, price, wholesale, bottle_dep, sales_tax,
Severity: Major
Found in chezbetty/models/item.py - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                            if single_item_barcode_sub == single_barcode:
                                return True
            return False
    Severity: Major
    Found in chezbetty/models/item.py - About 45 mins to fix

      Function from_barcode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_barcode(cls, barcode):
              item_list = DBSession.query(cls).filter(cls.barcode.ilike('%{}%'.format(barcode))).all()
              for item in item_list:
                  #split string into individual barcodes
                  item_barcode_sub = item.barcode.split(';')
      Severity: Minor
      Found in chezbetty/models/item.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

      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

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

          @classmethod
          def from_barcode(cls, barcode):
              item_list = DBSession.query(cls).filter(cls.barcode.ilike('%{}%'.format(barcode))).all()
              for item in item_list:
                  #split string into individual barcodes
      Severity: Major
      Found in chezbetty/models/item.py and 1 other location - About 6 hrs to fix
      chezbetty/models/box.py on lines 29..40

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

      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

          @classmethod
          def from_fuzzy(cls, search_str):
              return DBSession.query(cls)\
                              .filter(or_(
                                  cls.barcode.ilike('%{}%'.format(search_str)),
      Severity: Major
      Found in chezbetty/models/item.py and 1 other location - About 2 hrs to fix
      chezbetty/models/box.py on lines 42..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 61.

      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

          @classmethod
          def exists_name(cls, name):
              return DBSession.query(func.count(cls.id).label('c'))\
                              .filter(cls.name == name).one().c > 0
      Severity: Major
      Found in chezbetty/models/item.py and 1 other location - About 2 hrs to fix
      chezbetty/models/box.py on lines 71..74

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

      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 3 locations. Consider refactoring.
      Open

          @classmethod
          def count(cls):
              return DBSession.query(func.count(cls.id).label('c'))\
                              .filter(cls.enabled).one().c
      Severity: Major
      Found in chezbetty/models/item.py and 2 other locations - About 1 hr to fix
      chezbetty/models/box.py on lines 56..59
      chezbetty/models/vendor.py on lines 32..35

      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

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

          @classmethod
          def disabled(cls):
              return DBSession.query(cls)\
                              .filter(cls.enabled==False)\
                              .order_by(cls.name).all()
      Severity: Major
      Found in chezbetty/models/item.py and 8 other locations - About 1 hr to fix
      chezbetty/models/box.py on lines 65..69
      chezbetty/models/ephemeron.py on lines 21..25
      chezbetty/models/pool.py on lines 39..43
      chezbetty/models/pool.py on lines 46..50
      chezbetty/models/reimbursee.py on lines 32..36
      chezbetty/models/tag.py on lines 22..26
      chezbetty/models/user.py on lines 228..232
      chezbetty/models/vendor.py on lines 26..30

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

      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 5 locations. Consider refactoring.
      Open

          @classmethod
          def all(cls):
              return DBSession.query(cls)\
                              .filter(cls.enabled)\
                              .order_by(cls.name).all()
      Severity: Major
      Found in chezbetty/models/item.py and 4 other locations - About 55 mins to fix
      chezbetty/models/box.py on lines 50..54
      chezbetty/models/reimbursee.py on lines 25..29
      chezbetty/models/user.py on lines 186..190
      chezbetty/models/vendor.py on lines 20..24

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

      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

      There are no issues that match your filters.

      Category
      Status