goods/models/goods.py
Function get_tax_rate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_tax_rate(self, goods, partner, type):
"""
获得税率
如果商品上没有税率,则逐级取商品分类上的税率;
商品税率和业务伙伴税率做比较:如果都存在,取小的;其中一个存在取该值;都不存在取公司上的进/销项税
- Read upRead up
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
Open
return self.env.user.company_id.import_tax_rate
Avoid too many return
statements within this function. Open
Open
return partner_tax_rate
Avoid too many return
statements within this function. Open
Open
return self.env.user.company_id.output_tax_rate
Line too long (85 > 79 characters) Open
Open
goods_tax_rate = self.get_parent_tax_rate(goods.goods_class_id.parent_id)
- Read upRead up
- Exclude checks
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
Open
help="Those categories are used to group similar products for point of sale.")
- Read upRead up
- Exclude checks
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
Open
if not att_dict.has_key(line.category_id):
- Read upRead up
- Exclude checks
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')