kiwitcms/Kiwi

View on GitHub

Showing 239 of 376 total issues

Function preProcessData has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function preProcessData (data, callback) {
  const caseIds = []
  data.forEach(function (element) {
    caseIds.push(element.id)
  })
Severity: Minor
Found in tcms/testcases/static/testcases/js/search.js - About 1 hr to fix

    Function hookIntoPagination has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function hookIntoPagination (tableSelector, table) {
      const updateCurrentPage = function (table) {
        const info = table.page.info()
        $('.current-page').val(info.page + 1)
        $('.total-pages').html(info.pages)
    Severity: Minor
    Found in tcms/static/js/pagination.js - About 1 hr to fix

      Function getTestCaseRowContent has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getTestCaseRowContent (rowContent, testCase, permissions) {
        const row = $(rowContent)
      
        row[0].firstElementChild.dataset.testcasePk = testCase.id
        row.find('.js-test-case-link').html(`TC-${testCase.id}: ${testCase.summary}`).attr('href', `/case/${testCase.id}/`)
      Severity: Minor
      Found in tcms/testplans/static/testplans/js/get.js - About 1 hr to fix

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

                    if isinstance(item, str):
                        result_list[index] = html.escape(item)
                    elif isinstance(item, timedelta):
                        result_list[index] = item.total_seconds()
                    elif isinstance(item, dict):
        Severity: Major
        Found in tcms/handlers.py and 1 other location - About 1 hr to fix
        tcms/handlers.py on lines 57..61

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

        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

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

                for (index, item) in enumerate(result_list):
                    if isinstance(item, timedelta):
                        result_list[index] = item.total_seconds()
                    elif isinstance(item, dict):
                        __class__.escape_dict(item)
        Severity: Major
        Found in tcms/handlers.py and 1 other location - About 1 hr to fix
        tcms/handlers.py on lines 20..25

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

        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 clone has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def clone(self, new_author, test_plans):
                values = self.__dict__.copy()
                del values["_state"]
                del values["id"]
                if "sortkey" in values:
        Severity: Minor
        Found in tcms/testcases/models.py - 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 applyStyleToCell has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function applyStyleToCell (cell) {
          const cellElement = cell[1]
          if (cellElement) {
            const cellChildren = cellElement.children
            if (cellChildren) {
        Severity: Minor
        Found in tcms/telemetry/static/telemetry/js/testing/status-matrix.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 create_execution has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_execution(  # pylint: disable=too-many-arguments
                self,
                case,
                assignee=None,
                build=None,
        Severity: Minor
        Found in tcms/testruns/models.py - 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 addLinkToExecutions has 31 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 ajax has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              ajax: function (data, callback, settings) {
                const params = {}
          
                if ($('#id_summary').val()) {
                  params.summary__icontains = $('#id_summary').val()
          Severity: Minor
          Found in tcms/bugs/static/bugs/js/search.js - About 1 hr to fix

            Function preProcessData has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function preProcessData (data, callback) {
              const runIds = []
              const planIds = []
              data.forEach(function (element) {
                runIds.push(element.id)
            Severity: Minor
            Found in tcms/testruns/static/testruns/js/search.js - About 1 hr to fix

              Function ajax has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  ajax: function (data, callback, settings) {
                    const params = {}
              
                    if ($('#id_name').val()) {
                      params.name__icontains = $('#id_name').val()
              Severity: Minor
              Found in tcms/testplans/static/testplans/js/search.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 parse_translation_string has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def parse_translation_string(self, filename, lines):
                        startline = 0
                        startcol = 0
                        blocktrans_string = ""
                
                
                Severity: Minor
                Found in kiwi_lint/similar_string.py - 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 visit_call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def visit_call(self, node):
                        if node.func.as_string().endswith("Field") and node.keywords:
                            for keyword in node.keywords:
                                if keyword.arg == "label":
                                    self.add_message("form-field-label-used", node=node)
                Severity: Minor
                Found in kiwi_lint/forms.py - 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 create_permissions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                def create_permissions(
                    app_config,
                    verbosity=2,
                    interactive=True,
                    using=DEFAULT_DB_ALIAS,
                Severity: Minor
                Found in tcms/bugs/management.py - 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 advancedSearchAndAddTestCases has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function advancedSearchAndAddTestCases (objId, rpcMethod, href, errorMessage) {
                  window.addTestCases = function (testCaseIDs, sender) {
                    let rpcErrors = 0
                
                    // close the popup
                Severity: Minor
                Found in tcms/static/js/utils.js - About 1 hr to fix

                  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

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

                            if ($('#id_after_start_date').val()) {
                              params.start_date__gte = $('#id_after_start_date').data('DateTimePicker').date().format('YYYY-MM-DD 00:00:00')
                            }
                      Severity: Major
                      Found in tcms/testruns/static/testruns/js/search.js and 13 other locations - About 1 hr to fix
                      tcms/bugs/static/bugs/js/search.js on lines 36..38
                      tcms/bugs/static/bugs/js/search.js on lines 40..42
                      tcms/testcases/static/testcases/js/search.js on lines 65..67
                      tcms/testcases/static/testcases/js/search.js on lines 69..71
                      tcms/testplans/static/testplans/js/search.js on lines 44..46
                      tcms/testplans/static/testplans/js/search.js on lines 48..50
                      tcms/testruns/static/testruns/js/search.js on lines 56..58
                      tcms/testruns/static/testruns/js/search.js on lines 60..62
                      tcms/testruns/static/testruns/js/search.js on lines 64..66
                      tcms/testruns/static/testruns/js/search.js on lines 68..70
                      tcms/testruns/static/testruns/js/search.js on lines 72..74
                      tcms/testruns/static/testruns/js/search.js on lines 76..78
                      tcms/testruns/static/testruns/js/search.js on lines 80..82

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language