okcashpro/okshop

View on GitHub

Showing 56 of 130 total issues

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

            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

            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

            Avoid too many return statements within this function.
            Open

                    return redirect('shop:cart')
            Severity: Major
            Found in shop/views.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return render(request, 'shop/checkout3.html', {'checkout': chkout})
              Severity: Major
              Found in shop/views.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return self.outside_price
                Severity: Major
                Found in shop/models.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return -self.get_score()
                  Severity: Major
                  Found in shop/models.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return render(request, 'shop/checkout2.html',
                    Severity: Major
                    Found in shop/views.py - About 30 mins to fix

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

                      def get_key(request):
                          if request.method == 'POST' and 'purchaseid' in request.POST and \
                             'keyid' in request.POST:
                              try:
                                  purchase = PurchaseItem.objects.get(purchase__by=request.user,
                      Severity: Minor
                      Found in shop/views.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

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

                      def api_newwallet(request):
                          response = {'status': ""}
                          errors = []
                          if request.method == 'POST' and 'wallet_name' in request.POST:
                              if len(request.POST['wallet_name']) > 30:
                      Severity: Minor
                      Found in shop/views.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

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

                          def get_shipping_price(self):
                              if not self.cached_shipping:
                                  s = 0
                                  for item in self.cart.cartentry_set.filter(
                                          product__stock__gte=F('quantity'), product__physical=True):
                      Severity: Minor
                      Found in shop/models.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