kiwitcms/Kiwi

View on GitHub

Showing 1,521 of 1,748 total issues

File views.py has 478 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

from datetime import datetime
from http import HTTPStatus

Severity: Minor
Found in tcms/testruns/views.py - About 7 hrs to fix

    File views.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    import datetime
    
    from django.utils.decorators import method_decorator
    Severity: Minor
    Found in tcms/testplans/views.py - About 5 hrs to fix

      File serializer.py has 382 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      
      from datetime import datetime
      from datetime import timedelta
      from itertools import groupby
      Severity: Minor
      Found in tcms/rpc/serializer.py - About 5 hrs to fix

        File tcms_actions.js has 376 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        if (!jQ) {
            var jQ = $;
        }
        
        // Create a dictionary to avoid polluting the global namespace:
        Severity: Minor
        Found in tcms/static/js/tcms_actions.js - About 5 hrs to fix

          Function TableDnD has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

          function TableDnD() {
              /** Keep hold of the current drag object if any */
              this.dragObject = null;
              /** The current mouse offset */
              this.mouseOffset = null;
          Severity: Minor
          Found in tcms/static/js/lib/tablednd.js - About 4 hrs 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 post has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def post(self, request):
                  if not self._is_request_data_valid(request):
                      return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
          
                  # Do the clone action
          Severity: Minor
          Found in tcms/testcases/views.py - About 3 hrs 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

          Cyclomatic complexity is too high in method list. (17)
          Open

              @classmethod
              def list(cls, query, plan=None):
                  """List the cases with request"""
                  from django.db.models import Q
          
          
          Severity: Minor
          Found in tcms/testcases/models.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          File models.py has 315 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          from django.conf import settings
          from django.urls import reverse
          from django.db import models
          from django.utils.translation import override
          Severity: Minor
          Found in tcms/testcases/models.py - About 3 hrs to fix

            File testcase.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            
            from django.forms import EmailField, ValidationError
            
            from modernrpc.core import rpc_method, REQUEST_KEY
            Severity: Minor
            Found in tcms/rpc/api/testcase.py - About 3 hrs to fix

              Cyclomatic complexity is too high in function update. (15)
              Open

              @permissions_required('testruns.change_testrun')
              @rpc_method(name='TestRun.update')
              def update(run_id, values):
                  """
                  .. function:: XML-RPC TestRun.update(run_id, values)
              Severity: Minor
              Found in tcms/rpc/api/testrun.py by radon

              Cyclomatic Complexity

              Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

              Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

              Construct Effect on CC Reasoning
              if +1 An if statement is a single decision.
              elif +1 The elif statement adds another decision.
              else +0 The else statement does not cause a new decision. The decision is at the if.
              for +1 There is a decision at the start of the loop.
              while +1 There is a decision at the while statement.
              except +1 Each except branch adds a new conditional path of execution.
              finally +0 The finally block is unconditionally executed.
              with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
              assert +1 The assert statement internally roughly equals a conditional statement.
              Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
              Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

              Source: http://radon.readthedocs.org/en/latest/intro.html

              Cyclomatic complexity is too high in method clone. (12)
              Open

                  def clone(self, name=None, product=None, version=None,
                            new_author=None, set_parent=False, copy_testcases=False, **kwargs):
                      """Clone this plan
              
                      :param str name: New name of cloned plan. If not passed, make_cloned_name is called
              Severity: Minor
              Found in tcms/testplans/models.py by radon

              Cyclomatic Complexity

              Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

              Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

              Construct Effect on CC Reasoning
              if +1 An if statement is a single decision.
              elif +1 The elif statement adds another decision.
              else +0 The else statement does not cause a new decision. The decision is at the if.
              for +1 There is a decision at the start of the loop.
              while +1 There is a decision at the while statement.
              except +1 Each except branch adds a new conditional path of execution.
              finally +0 The finally block is unconditionally executed.
              with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
              assert +1 The assert statement internally roughly equals a conditional statement.
              Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
              Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

              Source: http://radon.readthedocs.org/en/latest/intro.html

              File models.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # -*- coding: utf-8 -*-
              import datetime
              from collections import namedtuple
              
              from django.conf import settings
              Severity: Minor
              Found in tcms/testruns/models.py - About 2 hrs to fix

                Function serializeFormData has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                function serializeFormData(options) {
                  var form = options.form;
                  var container = options.zoneContainer;
                  var selection = options.casesSelection;
                  var hashable = options.hashable || false;
                Severity: Minor
                Found in tcms/static/js/testplan_actions.js - About 2 hrs 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

                Cyclomatic complexity is too high in method post. (11)
                Open

                    def post(self, request):
                        if not self._is_request_data_valid(request):
                            return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
                
                        # Do the clone action
                Severity: Minor
                Found in tcms/testcases/views.py by radon

                Cyclomatic Complexity

                Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                Construct Effect on CC Reasoning
                if +1 An if statement is a single decision.
                elif +1 The elif statement adds another decision.
                else +0 The else statement does not cause a new decision. The decision is at the if.
                for +1 There is a decision at the start of the loop.
                while +1 There is a decision at the while statement.
                except +1 Each except branch adds a new conditional path of execution.
                finally +0 The finally block is unconditionally executed.
                with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                assert +1 The assert statement internally roughly equals a conditional statement.
                Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                Source: http://radon.readthedocs.org/en/latest/intro.html

                Function updateCaseRunStatus has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                var updateCaseRunStatus = function(e) {
                  e.stopPropagation();
                  e.preventDefault();
                  var container = jQ(this).parents().eq(3);
                  var parent = container.parent();
                Severity: Minor
                Found in tcms/static/js/testrun_actions.js - About 2 hrs 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 update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                def update(user_id, values, **kwargs):
                    """
                    .. function:: XML-RPC User.update(user_id, values)
                
                        Updates the fields of the selected user. Can be used to update
                Severity: Minor
                Found in tcms/rpc/api/user.py - About 2 hrs 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

                Cyclomatic complexity is too high in function update. (10)
                Open

                @rpc_method(name='User.update')
                def update(user_id, values, **kwargs):
                    """
                    .. function:: XML-RPC User.update(user_id, values)
                
                
                Severity: Minor
                Found in tcms/rpc/api/user.py by radon

                Cyclomatic Complexity

                Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                Construct Effect on CC Reasoning
                if +1 An if statement is a single decision.
                elif +1 The elif statement adds another decision.
                else +0 The else statement does not cause a new decision. The decision is at the if.
                for +1 There is a decision at the start of the loop.
                while +1 There is a decision at the while statement.
                except +1 Each except branch adds a new conditional path of execution.
                finally +0 The finally block is unconditionally executed.
                with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                assert +1 The assert statement internally roughly equals a conditional statement.
                Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                Source: http://radon.readthedocs.org/en/latest/intro.html

                Function list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def list(cls, query, plan=None):
                        """List the cases with request"""
                        from django.db.models import Q
                
                        if not plan:
                Severity: Minor
                Found in tcms/testcases/models.py - About 2 hrs 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 register has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                def register(request):
                    """Register method of account"""
                    if request.method == 'POST':
                        form = forms.RegistrationForm(data=request.POST, files=request.FILES)
                        if form.is_valid():
                Severity: Minor
                Found in tcms/kiwi_auth/views.py - About 2 hrs 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 clean has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def clean(self, value):
                        """
                        Form-validation:  accept a string/integer.
                        Looks at both email address and real name.
                        """
                Severity: Minor
                Found in tcms/core/forms/fields.py - About 2 hrs 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