coopdevs/lazona_connector

View on GitHub

Showing 7 of 9 total issues

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

def update_delivery_status(delivery_id, email_notify=False):
    from api.models import Shipment, ShipmentStatus

    delivery_status = Client().update_delivery_status(delivery_id)
    if delivery_status and delivery_id:
Severity: Minor
Found in api/tasks.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 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in koiki/woocommerce/resources.py - About 1 hr to fix

    Function create_delivery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_delivery(self, order):
            create_delivery = CreateDelivery(order)
            req_body_create_delivery = create_delivery.body()
            self.logger.info(
                'Koiki request to {}. body={}'.format(
    Severity: Minor
    Found in koiki/client.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 _get_shipment_status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_shipment_status(self, status_code):
            from api.models import ShipmentStatus
            if self.is_errored():
                return ShipmentStatus.ERROR_FROM_TRACKING
            else:
    Severity: Minor
    Found in koiki/delivery_status.py - About 45 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 _by_method has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def _by_method(self, shipping_lines):
            by_method = defaultdict(list)
            method_id = None
            nometadata = False
            for line_item in shipping_lines:
    Severity: Minor
    Found in koiki/woocommerce/order.py - About 35 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

    Avoid too many return statements within this function.
    Open

            return False
    Severity: Major
    Found in koiki/delivery_status.py - About 30 mins to fix

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

          def search_email(self, email):
              args = [email, ["Accounts", "Contacts"], 0, 1, "", ["id"], False, False]
              self.logger.info("SugarCRM searching email in CRM: {}".format(email))
              response = self._api_request("search_by_module", args)
              result = response.json()
      Severity: Minor
      Found in sugarcrm/client.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