tobyqin/testcube

View on GitHub

Showing 94 of 96 total issues

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

def result_reset(request, result_id):
    """POST view for result reset"""
    result_id = int(result_id)

    if request.method == 'POST':
Severity: Major
Found in testcube/core/views.py and 1 other location - About 1 day to fix
testcube/core/views.py on lines 72..90

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

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

def result_analysis(request, result_id):
    """POST view for result analysis"""
    result_id = int(result_id)

    if request.method == 'POST':
Severity: Major
Found in testcube/core/views.py and 1 other location - About 1 day to fix
testcube/core/views.py on lines 93..111

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

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

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

import re
from datetime import datetime, timezone, timedelta

from django.db.models import Q
from ipware.ip import get_ip
Severity: Major
Found in testcube/core/api/views.py - About 1 day to fix

    Function renderRunDetailChart has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function renderRunDetailChart() {
            if (window.app.runList === undefined
                || window.app.summaryInfo === undefined
                || window.app.summaryInfo.result_total === 0) {
                loadingCompleted();
    Severity: Major
    Found in testcube/static/modules/chart-support.js - About 4 hrs to fix

      Function renderResultDetailChart has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function renderResultDetailChart(callback) {
              if (window.app.resultHistory === undefined
                  || window.app.summaryInfo === undefined) {
                  loadingCompleted();
                  return;
      Severity: Major
      Found in testcube/static/modules/chart-support.js - About 3 hrs to fix

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

            if request.method == 'POST':
                form = ResetPasswordForm(request.POST, instance=request.user)
                if form.is_valid():
                    form.save()
                    return render(request, 'reset_password.html', {'form': form, 'message': 'Reset success.'})
        Severity: Major
        Found in testcube/users/views.py and 1 other location - About 3 hrs to fix
        testcube/users/views.py on lines 77..84

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

        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 request.method == 'POST':
                form = UserProfileForm(request.POST, instance=request.user)
                if form.is_valid():
                    form.save()
                    return render(request, 'user_profile.html', {'form': form,
        Severity: Major
        Found in testcube/users/views.py and 1 other location - About 3 hrs to fix
        testcube/users/views.py on lines 62..69

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

        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

                function runListTableDataHandler(data) {
                    data.total = data.count;
                    data.rows = data.results;
                    for (let r of data.results) {
                        r.passing_rate = {
        Severity: Major
        Found in testcube/static/modules/run-list.js and 1 other location - About 3 hrs to fix
        testcube/static/modules/run-detail.js on lines 61..73

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

        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

                function runListTableDataHandler(data) {
                    data.total = data.count;
                    data.rows = data.results;
                    for (let r of data.results) {
                        r.passing_rate = {
        Severity: Major
        Found in testcube/static/modules/run-detail.js and 1 other location - About 3 hrs to fix
        testcube/static/modules/run-list.js on lines 45..57

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

        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

                $.get('/api/products/recent/', function (data) {
                    for (let obj of data.results) {
                        $('#product-picker').append(`<option value="${obj.id}">${obj.name}</option>`);
                        $('.selectpicker').selectpicker('refresh');
                    }
        Severity: Major
        Found in testcube/static/modules/table-support.js and 1 other location - About 2 hrs to fix
        testcube/static/modules/table-support.js on lines 171..176

        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

                $.get('/api/teams/recent/', function (data) {
                    for (let obj of data.results) {
                        $('#team-picker').append(`<option value="${obj.id}">${obj.name}</option>`);
                        $('.selectpicker').selectpicker('refresh');
                    }
        Severity: Major
        Found in testcube/static/modules/table-support.js and 1 other location - About 2 hrs to fix
        testcube/static/modules/table-support.js on lines 165..170

        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

                if (e.target.id === 'team-picker') {
                    let picker = $('#team-picker');
                    let value = picker.selectpicker('val');
                    if (value) {
                        toolbarFilter.team = value;
        Severity: Major
        Found in testcube/static/modules/table-support.js and 1 other location - About 2 hrs to fix
        testcube/static/modules/table-support.js on lines 150..161

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

        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 (e.target.id === 'product-picker') {
                    let picker = $('#product-picker');
                    let value = picker.selectpicker('val');
                    if (value) {
                        toolbarFilter.product = value;
        Severity: Major
        Found in testcube/static/modules/table-support.js and 1 other location - About 2 hrs to fix
        testcube/static/modules/table-support.js on lines 138..149

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

        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

        File chart-support.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        define(['moment', 'c3', 'd3', './utils'], function (moment, c3, d3, utils) {
        
            "use strict";
            let config = {};
        
        
        Severity: Minor
        Found in testcube/static/modules/chart-support.js - About 2 hrs to fix

          Function handler has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def handler(self, request, pk=None):
                  """
                  Handle single reset result.
                  1. update current reset result with provided info.
                  2. create error object if required.
          Severity: Minor
          Found in testcube/core/api/views.py - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

              @action(detail=False)
              def recent(self, request):
                  """get recent teams"""
                  self.queryset = Product.objects.order_by('name').all()
                  self.serializer_class = ProductListSerializer
          Severity: Major
          Found in testcube/core/api/views.py and 1 other location - About 2 hrs to fix
          testcube/core/api/views.py on lines 46..51

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

          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

              @action(detail=False)
              def recent(self, request):
                  """get recent teams"""
                  self.queryset = Team.objects.order_by('name').all()
                  self.serializer_class = TeamListSerializer
          Severity: Major
          Found in testcube/core/api/views.py and 1 other location - About 2 hrs to fix
          testcube/core/api/views.py on lines 60..65

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

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

                  function resultDetailSummaryPostEvent(data) {
                      if (data[0] === undefined) return;
                      let result = data[0];
                      let stderr = "Nothing found.";
                      let stdout = "Nothing found.";
          Severity: Major
          Found in testcube/static/modules/result-detail.js - About 2 hrs to fix

            Function runDetailSummaryPostEvent has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function runDetailSummaryPostEvent(data) {
                        if (data[0] === undefined) return;
            
                        let run = data[0];
                        let nav = `${run.id} - ${run.name}`;
            Severity: Major
            Found in testcube/static/modules/run-detail.js - About 2 hrs to fix

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

              class ResultFilter(filters.FilterSet):
                  run = filters.RelatedFilter(TestRunFilter, name='test_run', queryset=TestRun.objects.all())
              
                  class Meta:
                      model = TestResult
              Severity: Major
              Found in testcube/core/api/filters.py and 2 other locations - About 1 hr to fix
              testcube/core/api/filters.py on lines 20..25
              testcube/core/api/filters.py on lines 28..33

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

              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