kiwitcms/Kiwi

View on GitHub

Showing 1,496 of 1,724 total issues

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

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

from http import HTTPStatus

from django.conf import settings
Severity: Minor
Found in tcms/testruns/views.py - About 7 hrs to fix

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

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

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

      # -*- coding: utf-8 -*-
      
      from django.contrib import messages
      from django.contrib.auth.decorators import permission_required
      from django.core.exceptions import ObjectDoesNotExist
      Severity: Minor
      Found in tcms/testplans/views.py - 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

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

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

          File tcms_actions.js has 337 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 4 hrs to fix

            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. (16)
            Open

                @classmethod
                def list(cls, query, plan=None):
                    """List the cases with request"""
            
                    if not plan:
            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

            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

            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

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

            # -*- coding: utf-8 -*-
            import vinaigrette
            from django.conf import settings
            from django.db import models
            from django.db.models import ObjectDoesNotExist
            Severity: Minor
            Found in tcms/testcases/models.py - About 2 hrs to fix

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

              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

              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

              Cyclomatic complexity is too high in method stats_executions_status. (9)
              Open

                  @override('en')
                  def stats_executions_status(self, statuses=None):
                      """
                          Get statistics based on executions' status
              
              
              Severity: Minor
              Found in tcms/testruns/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

              Cyclomatic complexity is too high in class UserField. (9)
              Open

              class UserField(forms.CharField):
                  """
                  Custom field type.
                  Will eventually support user selection
                  """
              Severity: Minor
              Found in tcms/core/forms/fields.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 post. (9)
              Open

                  def post(self, request, run_id):
                      # Selected cases' ids to add to run
                      test_cases_ids = request.POST.getlist('case')
                      if not test_cases_ids:
                          # user clicked Update button without selecting new Test Cases
              Severity: Minor
              Found in tcms/testruns/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

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

              @permissions_required('testplans.change_testplan')
              @rpc_method(name='TestPlan.update')
              def update(plan_id, values):
                  """
                  .. function:: XML-RPC TestPlan.update(plan_id, values)
              Severity: Minor
              Found in tcms/rpc/api/testplan.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

              Severity
              Category
              Status
              Source
              Language