kiwitcms/Kiwi

View on GitHub
tcms/testruns/static/testruns/js/get.js

Summary

Maintainability
F
5 days
Test Coverage

File get.js has 720 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { fetchBugDetails } from '../../../../static/js/bugs'
import { jsonRPC } from '../../../../static/js/jsonrpc'
import { propertiesCard } from '../../../../static/js/properties'
import { tagsCard } from '../../../../static/js/tags'
import {
Severity: Major
Found in tcms/testruns/static/testruns/js/get.js - About 1 day to fix

    Function pageTestrunsGetReadyHandler has 161 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function pageTestrunsGetReadyHandler () {
        permissions.removeTag = $('#test_run_pk').data('perm-remove-tag') === 'True'
        permissions.addComment = $('#test_run_pk').data('perm-add-comment') === 'True'
        permissions.removeComment = $('#test_run_pk').data('perm-remove-comment') === 'True'
    
    
    Severity: Major
    Found in tcms/testruns/static/testruns/js/get.js - About 6 hrs to fix

      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

        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

          Function addLinkToExecutions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function addLinkToExecutions (testExecutionIDs) {
              // remove all previous event handlers
              $('.add-hyperlink-form').off('submit')
          
              // this handler must be here, because if we bind it when the page is loaded.
          Severity: Minor
          Found in tcms/testruns/static/testruns/js/get.js - About 1 hr to fix

            Function filterTestExecutionsByProperty has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function filterTestExecutionsByProperty (runId, executions, filterBy, filterValue) {
                // no input => show all rows
                if (filterValue.trim().length === 0) {
                    $('.test-execution-element').show()
                    return
            Severity: Minor
            Found in tcms/testruns/static/testruns/js/get.js - About 1 hr 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 renderTestExecutionRow has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function renderTestExecutionRow (testExecution) {
                // refresh the internal data structure b/c some fields are used
                // to render the expand area and may have changed via bulk-update meanwhile
                testExecution.status__name = $('#test_run_pk').data(`trans-execution-status-${testExecution.status}`)
                allExecutions[testExecution.id] = testExecution
            Severity: Minor
            Found in tcms/testruns/static/testruns/js/get.js - About 1 hr to fix

              Function filterTestExecutionsByProperty has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function filterTestExecutionsByProperty (runId, executions, filterBy, filterValue) {
                  // no input => show all rows
                  if (filterValue.trim().length === 0) {
                      $('.test-execution-element').show()
                      return
              Severity: Minor
              Found in tcms/testruns/static/testruns/js/get.js - About 1 hr to fix

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

                function drawPercentBar (testExecutions, updateTestRun = false) {
                    let positiveCount = 0
                    let negativeCount = 0
                    const allCount = testExecutions.length
                    const statusCount = {}
                Severity: Minor
                Found in tcms/testruns/static/testruns/js/get.js - 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

                TODO found
                Open

                        // TODO: remove the page reload above and add the new case to the list

                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

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

                    $('#toolbar-filter').on('keyup', function () {
                        const filterValue = $(this).val().toLowerCase()
                        const filterBy = $('.js-toolbar-filter-options .selected')[0].dataset.filterType
                
                        filterTestExecutionsByProperty(
                Severity: Major
                Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 2 hrs to fix
                tcms/testplans/static/testplans/js/get.js on lines 455..465

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

                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

                        jsonRPC('TestCase.filter', query, function (filtered) {
                            // hide again if a previous async request showed something else
                            $('.test-execution-element').hide()
                            filtered.forEach(tc => $(`.test-execution-case-${tc.id}`).show())
                        })
                Severity: Major
                Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 1 hr to fix
                tcms/testplans/static/testplans/js/get.js on lines 702..706

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

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

                                        if (testCase.componentNames.length) {
                                            const componentsRow = row.find('.js-row-components')
                                            componentsRow.toggleClass('hidden')
                                            componentsRow.html(componentsRow.html() + testCase.componentNames.join(', '))
                                        }
                Severity: Major
                Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 1 hr to fix
                tcms/testruns/static/testruns/js/get.js on lines 670..674

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

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

                                        if (testCase.tagNames.length) {
                                            const tagsRow = row.find('.js-row-tags')
                                            tagsRow.toggleClass('hidden')
                                            tagsRow.html(tagsRow.html() + testCase.tagNames.join(', '))
                                        }
                Severity: Major
                Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 1 hr to fix
                tcms/testruns/static/testruns/js/get.js on lines 684..688

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

                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

                    $('#btn-search-cases').click(function () {
                        return advancedSearchAndAddTestCases(
                            testRunId, 'TestRun.add_case', $(this).attr('href'),
                            $('#test_run_pk').data('trans-error-adding-cases')
                        )
                Severity: Minor
                Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 55 mins to fix
                tcms/testplans/static/testplans/js/get.js on lines 62..67

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

                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

                    $('.change-assignee-bulk').click(function () {
                        $(this).parents('.dropdown').toggleClass('open')
                        changeAssigneeBulk()
                
                        return false
                Severity: Minor
                Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 50 mins to fix
                tcms/testruns/static/testruns/js/get.js on lines 126..131

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

                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

                    $('.update-case-text-bulk').click(function () {
                        $(this).parents('.dropdown').toggleClass('open')
                        updateCaseText()
                
                        return false
                Severity: Minor
                Found in tcms/testruns/static/testruns/js/get.js and 1 other location - About 50 mins to fix
                tcms/testruns/static/testruns/js/get.js on lines 119..124

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

                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

                There are no issues that match your filters.

                Category
                Status