okcashpro/okshop

View on GitHub

Showing 130 of 130 total issues

Avoid deeply nested control flow statements.
Open

                    if chkout.step <= 1 and len(addresses) > 0:
                        chkout.step = 1
                    else:
                        messages.warning(request, "Not enough balance!")
                        return redirect("shop:cart")
Severity: Major
Found in shop/views.py - About 45 mins to fix

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

            if not hasattr(verify.user, 'userextra'):
                ue = UserExtra(user=verify.user)
                ue.save()
    Severity: Minor
    Found in shop/views.py and 1 other location - About 45 mins to fix
    shop/views.py on lines 362..364

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

    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

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

        if 'file' in request.FILES and\
           0 < len(request.POST.get('name', '')) <= 200:
    Severity: Minor
    Found in shop/views.py and 1 other location - About 45 mins to fix
    shop/views.py on lines 1098..1099

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

    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

        def get_shipping_price(self):
            s = 0
            for item in self.purchaseitem_set.all():
                s += item.shipping_price
            return s
    Severity: Minor
    Found in shop/models.py and 1 other location - About 45 mins to fix
    shop/models.py on lines 471..475

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

    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

        if not hasattr(request.user, 'cart'):
            c = Cart(user=request.user)
            c.save()
    Severity: Minor
    Found in shop/views.py and 1 other location - About 45 mins to fix
    shop/views.py on lines 232..234

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

    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

    Avoid deeply nested control flow statements.
    Open

                            if p.product is None:
                                p.product = product
                                p.save()
                        except ObjectDoesNotExist:
    Severity: Major
    Found in shop/views.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if i.uuid not in request.POST.getlist('images', []):
                              i.delete()
                  else:
      Severity: Major
      Found in shop/views.py - About 45 mins to fix

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

            def get_item_price(self):
                s = 0
                for item in self.purchaseitem_set.all():
                    s += item.price
                return s
        Severity: Minor
        Found in shop/models.py and 1 other location - About 45 mins to fix
        shop/models.py on lines 477..481

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

        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

        Avoid deeply nested control flow statements.
        Open

                            for item in chkout.cart.cartentry_set.all():
                                t = False
                                if not item.product.ships_to(chkout.shipping):
                                    messages.warning(
                                        request,
        Severity: Major
        Found in shop/views.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if country not in dict(countries):
                                  errors.append('%s is not a country!' % country)
                              else:
                                  sc = ShippingCountry(product=product, country=country)
                                  sc.save()
          Severity: Major
          Found in shop/views.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if country not in dict(countries):
                                    errors.append('%s is not a country!' % country)
                        if 'free-shipping' in request.POST:
            Severity: Major
            Found in shop/views.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if country in dict(countries):
                                      c = ShippingCountry(country=country, product=p)
                                      c.save()
                          p.save()
              Severity: Major
              Found in shop/views.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if 0 < len(request.POST['zip'].strip()) <= 15 and\
                                            0 < len(request.POST['name'].strip()) <= 200 and\
                                            request.POST['address1'].strip() != '' and\
                                            request.POST['country'].strip() in dict(countries)\
                                            and request.POST['state'].strip() != '':
                Severity: Major
                Found in shop/views.py - About 45 mins to fix

                  Function register_view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def register_view(request):
                      if request.method == 'POST':
                          form = RegisterForm(request.POST)
                          if form.is_valid():
                              messages.success(request,
                  Severity: Minor
                  Found in shop/views.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

                  Avoid deeply nested control flow statements.
                  Open

                                      if chkout.get_price() == Decimal(0) and\
                                       len(addresses) == 0:
                                          a = Wallet(user=request.user, label='default')
                                          a.save()
                                          chkout.wallet = a
                  Severity: Major
                  Found in shop/views.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if user.userextra.verify_2fa(
                                                request.POST.get('2facode', '')):
                                            login(request, user)
                                            messages.success(request,
                                                             "Welcome back, %s!" % user.username)
                    Severity: Major
                    Found in shop/views.py - About 45 mins to fix

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

                                          (self.get_shipping_price(address)
                                           + self.get_item_price()*ammount) * Decimal(0.995))
                      Severity: Minor
                      Found in shop/models.py and 1 other location - About 35 mins to fix
                      shop/models.py on lines 137..138

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

                      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 upload_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def upload_file(request, id):
                          product = get_object_or_404(Product, id=id, physical=False)
                          if product.seller != request.user:
                              e = {
                                  'status': 403,
                      Severity: Minor
                      Found in shop/views.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

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

                                          (self.get_shipping_price(address)
                                           + self.get_item_price()*ammount) * Decimal(0.005))
                      Severity: Minor
                      Found in shop/models.py and 1 other location - About 35 mins to fix
                      shop/models.py on lines 141..142

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

                      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 shop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def shop(request, user):
                          try:
                              usershop = get_object_or_404(UserShop, user__username=user)
                          except Http404:
                              if User.objects.filter(username=user).count() > 0:
                      Severity: Minor
                      Found in shop/views.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

                      Severity
                      Category
                      Status
                      Source
                      Language