Showing 49 of 117 total issues
CartService
has 55 functions (exceeds 20 allowed). Consider refactoring. Open
class CartService(Component):
_inherit = "shopinvader.abstract.sale.service"
_name = "shopinvader.cart.service"
_usage = "cart"
File cart.py
has 466 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
# Copyright 2016 Akretion (http://www.akretion.com)
# Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# pylint: disable=consider-merging-classes-inherited
File shopinvader_backend.py
has 359 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
# Copyright 2017 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
Function _synchronize_all_binding_stock_level
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def _synchronize_all_binding_stock_level(self):
"""
The goal of this function is to compute the new stock information
and update them in the data field. If data have change and the binding
is in done state we force it to 'to_update'.
- 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
Function name_get
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def name_get(self):
res = []
for partner in self:
name = partner.name or ""
- 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
Function import_images
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def import_images(self):
errors = []
file_csv = StringIO.StringIO(base64.decodestring(self.file_csv))
- 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
Function _onchange_shopinvader_backend_id
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _onchange_shopinvader_backend_id(self):
"""
Onchange for the shopinvader_backend_id field.
Auto fill some info based on active_ids and selected backend.
:return:
- 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
Function _action_product_toggle_active
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _action_product_toggle_active(self):
"""
Action a deactivation of a variant, if every variants are disabled:
disable the product too.
Also when a variant is enabled, the related shopinvader product
- 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
Function action_bind_categories
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def action_bind_categories(self):
for wizard in self.with_context(active_test=False):
if wizard.child_autobinding:
for categ_id in wizard.product_category_ids:
childs_cat = self.env["product.category"].search(
- 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
Function bind_products
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def bind_products(self):
for wizard in self:
binded_templates = wizard._get_binded_templates()
binding = self.env["shopinvader.variant"]
for product in wizard.product_ids:
- 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
Function _update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _update(self, cart, params):
is_coupon_code_specified = "coupon_code" in params
coupon_code = params.pop("coupon_code", None)
if is_coupon_code_specified:
if coupon_code is not None:
- 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
Function _bind_all_content
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _bind_all_content(self, model, bind_model, domain):
bind_model_obj = self.env[bind_model].with_context(active_test=False)
model_obj = self.env[model]
records = model_obj.search(domain)
binds = bind_model_obj.search(
- 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
Function _compute_shopinvader_variant
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _compute_shopinvader_variant(self):
lang = self._context.get("lang")
if not lang:
_logger.warning(
"No lang specified for getting the shopinvader variant "
- 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
Function _bind_categories
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _bind_categories(self, backend, lang, categories, parent_ids=None):
"""
This method is used to bind all categories recursively starting
from the higher level to the lower one
:param backend: backend on which we need to bind categories
- 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
Function _generic_compute_automatic_url_key
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _generic_compute_automatic_url_key(self):
records_by_lang = defaultdict(self.browse)
for record in self:
records_by_lang[record.lang_id] |= record
- 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
Function _inverse_name
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _inverse_name(self):
"""Try to revert the effect of :meth:`._compute_name`."""
for record in self:
names = record.name.split(", ", 1)
if record.is_company:
- 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
Consider simplifying this complex logical expression. Open
if record.is_company:
company = names[0]
contact_name = len(names) > 1 and names[1] or ""
else:
company = len(names) > 1 and names[0] or ""
Function _get_binded_templates
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _get_binded_templates(self):
"""
return a dict of binded shopinvader.product by product template id
:return:
"""
- 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
Function set_url
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_url(self, url_key):
""" Se a new url
backup old url
1 find url redirect true and same model_id
- 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
Function wrap_integrity_error
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def wrap_integrity_error(method):
@wraps(method)
def f(*args, **kwargs):
try:
r = method(*args, **kwargs)
- 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"