kiwitcms/Kiwi

View on GitHub

Showing 262 of 405 total issues

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

@permissions_required("testruns.view_environmentproperty")
@rpc_method(name="Environment.properties")
def properties(query=None):
    """
    .. function:: Environment.properties(query)
Severity: Major
Found in tcms/rpc/api/environment.py and 1 other location - About 4 hrs to fix
tcms/rpc/api/testcase.py on lines 546..571

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

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 3 locations. Consider refactoring.
Open

        tags.forEach(function (element) {
            if (tagsPerCase[element.case] === undefined) {
                tagsPerCase[element.case] = []
            }

Severity: Major
Found in tcms/testcases/static/testcases/js/search.js and 2 other locations - About 3 hrs to fix
tcms/testcases/static/testcases/js/search.js on lines 32..41
tcms/testplans/static/testplans/js/search.js on lines 23..32

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

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 3 locations. Consider refactoring.
Open

        tags.forEach(function (element) {
            if (tagsPerPlan[element.plan] === undefined) {
                tagsPerPlan[element.plan] = []
            }

Severity: Major
Found in tcms/testplans/static/testplans/js/search.js and 2 other locations - About 3 hrs to fix
tcms/testcases/static/testcases/js/search.js on lines 18..27
tcms/testcases/static/testcases/js/search.js on lines 32..41

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

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 3 locations. Consider refactoring.
Open

            components.forEach(function (element) {
                if (componentsPerCase[element.cases] === undefined) {
                    componentsPerCase[element.cases] = []
                }

Severity: Major
Found in tcms/testcases/static/testcases/js/search.js and 2 other locations - About 3 hrs to fix
tcms/testcases/static/testcases/js/search.js on lines 18..27
tcms/testplans/static/testplans/js/search.js on lines 23..32

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

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 renderAdditionalInformation has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function renderAdditionalInformation (testRunId, execution) {
    let linksQuery = { execution__run: testRunId }
    let casesQuery = { executions__run: testRunId }
    let componentQ = { cases__executions__run: testRunId }
    let tagsQ = { case__executions__run: testRunId }
Severity: Major
Found in tcms/testruns/static/testruns/js/get.js - About 3 hrs to fix

    File utils.js has 328 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { jsonRPC } from './jsonrpc'
    
    /*
        Used to update a select when something else changes.
    */
    Severity: Minor
    Found in tcms/static/js/utils.js - About 3 hrs to fix

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

      @permissions_required("testcases.add_category")
      @rpc_method(name="Category.create")
      def create(values):
          """
          .. function:: RPC Category.create(values)
      Severity: Major
      Found in tcms/rpc/api/category.py and 2 other locations - About 3 hrs to fix
      tcms/rpc/api/environment.py on lines 109..129
      tcms/rpc/api/version.py on lines 32..58

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

      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 3 locations. Consider refactoring.
      Open

      @rpc_method(name="PlanType.create")
      @permissions_required("testplans.add_plantype")
      def create(values):
          """
          .. function:: RPC PlanType.create(values)
      Severity: Major
      Found in tcms/rpc/api/plantype.py and 2 other locations - About 3 hrs to fix
      tcms/rpc/api/classification.py on lines 29..50
      tcms/rpc/api/product.py on lines 11..32

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

      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 3 locations. Consider refactoring.
      Open

      @rpc_method(name="Product.create")
      @permissions_required("management.add_product")
      def create(values):
          """
          .. function:: RPC Product.create(values)
      Severity: Major
      Found in tcms/rpc/api/product.py and 2 other locations - About 3 hrs to fix
      tcms/rpc/api/classification.py on lines 29..50
      tcms/rpc/api/plantype.py on lines 11..31

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

      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 3 locations. Consider refactoring.
      Open

      @rpc_method(name="Classification.create")
      @permissions_required("management.add_classification")
      def create(values):
          """
          .. function:: RPC Classification.create(values)
      Severity: Major
      Found in tcms/rpc/api/classification.py and 2 other locations - About 3 hrs to fix
      tcms/rpc/api/plantype.py on lines 11..31
      tcms/rpc/api/product.py on lines 11..32

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

      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 3 locations. Consider refactoring.
      Open

      @permissions_required("testruns.add_environment")
      @rpc_method(name="Environment.create")
      def create(values):
          """
          .. function:: RPC Environment.create(values)
      Severity: Major
      Found in tcms/rpc/api/environment.py and 2 other locations - About 3 hrs to fix
      tcms/rpc/api/category.py on lines 31..52
      tcms/rpc/api/version.py on lines 32..58

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

      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 3 locations. Consider refactoring.
      Open

      @permissions_required("management.add_version")
      @rpc_method(name="Version.create")
      def create(values):
          """
          .. function:: RPC Version.create(values)
      Severity: Major
      Found in tcms/rpc/api/version.py and 2 other locations - About 3 hrs to fix
      tcms/rpc/api/category.py on lines 31..52
      tcms/rpc/api/environment.py on lines 109..129

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

      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 drawTable has 94 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function drawTable () {
          $('#resultsTable').DataTable({
              pageLength: $('#navbar').data('defaultpagesize'),
              ajax: function (data, callbackF, settings) {
                  const query = {}
      Severity: Major
      Found in tcms/telemetry/static/telemetry/js/testing/execution-dashboard.js - About 3 hrs to fix

        File testrun.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        from django.forms.models import model_to_dict
        from modernrpc.core import REQUEST_KEY, rpc_method
        
        from tcms.management.models import Tag
        Severity: Minor
        Found in tcms/rpc/api/testrun.py - About 3 hrs to fix

          File types.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
              This module implements Kiwi TCMS interface to external issue tracking systems.
              Refer to each implementor class for integration specifics!
          """
          
          
          Severity: Minor
          Found in tcms/issuetracker/types.py - About 3 hrs to fix

            Function pageTestplansSearchReadyHandler has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

            export function pageTestplansSearchReadyHandler () {
                initializeDateTimePicker('#id_before')
                initializeDateTimePicker('#id_after')
            
                const rowsNotShownMessage = $('#main-element').data('trans-some-rows-not-shown')
            Severity: Minor
            Found in tcms/testplans/static/testplans/js/search.js - 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

            Function getExpandArea has 87 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getExpandArea (testExecution) {
                const container = $(`.test-execution-${testExecution.id}`)
            
                container.find('.test-execution-information .run-date').html(testExecution.stop_date || '-')
                container.find('.test-execution-information .build').html(testExecution.build__name)
            Severity: Major
            Found in tcms/testruns/static/testruns/js/get.js - About 3 hrs to fix

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

                  if (filterBy === 'component' || filterBy === 'tag') {
                      const query = { plan: planId }
                      query[`${filterBy}__name__icontains`] = filterValue
              
                      jsonRPC('TestCase.filter', query, function (filtered) {
              Severity: Major
              Found in tcms/testplans/static/testplans/js/get.js and 1 other location - About 3 hrs to fix
              tcms/testruns/static/testruns/js/get.js on lines 261..280

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

              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 (filterBy === 'is_automated' || filterBy === 'priority' || filterBy === 'category') {
                      const query = { executions__run: runId }
                      if (filterBy === 'is_automated') {
                          query[filterBy] = filterValue
                      } else if (filterBy === 'priority') {
              Severity: Major
              Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 3 hrs to fix
              tcms/testplans/static/testplans/js/get.js on lines 698..711

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

              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 drawTable has 79 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function drawTable () {
                  $('.js-spinner').show()
                  if (table) {
                      table.destroy()
              
              
              Severity: Major
              Found in tcms/telemetry/static/telemetry/js/testing/status-matrix.js - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language