osbzr/gooderp_addons

View on GitHub
goods/models/goods.py

Summary

Maintainability
A
3 hrs
Test Coverage

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

    def get_tax_rate(self, goods, partner, type):
        """
        获得税率
        如果商品上没有税率,则逐级取商品分类上的税率;
        商品税率和业务伙伴税率做比较:如果都存在,取小的;其中一个存在取该值;都不存在取公司上的进/销项税
Severity: Minor
Found in goods/models/goods.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

Avoid too many return statements within this function.
Open

                return self.env.user.company_id.import_tax_rate
Severity: Major
Found in goods/models/goods.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return partner_tax_rate
    Severity: Major
    Found in goods/models/goods.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return self.env.user.company_id.output_tax_rate
      Severity: Major
      Found in goods/models/goods.py - About 30 mins to fix

        Line too long (85 > 79 characters)
        Open

                    goods_tax_rate = self.get_parent_tax_rate(goods.goods_class_id.parent_id)
        Severity: Minor
        Found in goods/models/goods.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (86 > 79 characters)
        Open

                help="Those categories are used to group similar products for point of sale.")
        Severity: Minor
        Found in goods/models/goods.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        .has_key() is deprecated, use 'in'
        Open

                    if not att_dict.has_key(line.category_id):
        Severity: Minor
        Found in goods/models/goods.py by pep8

        The {}.has_key() method is removed in Python 3: use the 'in' operator.

        Okay: if "alph" in d:\n    print d["alph"]
        W601: assert d.has_key('alph')

        There are no issues that match your filters.

        Category
        Status