coopdevs/lazona_connector

View on GitHub

Showing 9 of 9 total issues

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

        migrations.AlterField(
            model_name='shipment',
            name='status',
            field=models.CharField(
                choices=[
Severity: Major
Found in api/migrations/0005_auto_20210802_1332.py and 1 other location - About 2 hrs to fix
api/migrations/0006_auto_20210802_1514.py on lines 12..23

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

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

    operations = [
        migrations.AlterField(
            model_name='shipment',
            name='status',
            field=models.CharField(
Severity: Major
Found in api/migrations/0006_auto_20210802_1514.py and 1 other location - About 2 hrs to fix
api/migrations/0005_auto_20210802_1332.py on lines 44..54

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

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

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