erikvw/django-collect-offline

View on GitHub

Showing 75 of 75 total issues

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

        migrations.CreateModel(
            name="Server",
            fields=[
                (
                    "created",
Severity: Major
Found in django_collect_offline/migrations/0001_initial.py and 1 other location - About 3 days to fix
django_collect_offline/migrations/0001_initial.py on lines 21..105

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

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

        migrations.CreateModel(
            name="Client",
            fields=[
                (
                    "created",
Severity: Major
Found in django_collect_offline/migrations/0001_initial.py and 1 other location - About 3 days to fix
django_collect_offline/migrations/0001_initial.py on lines 412..496

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

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 0001_initial.py has 500 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Generated by Django 2.0.6 on 2018-07-03 10:45

import _socket
from django.db import migrations, models
import django.db.models.deletion
Severity: Minor
Found in django_collect_offline/migrations/0001_initial.py - About 1 day to fix

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

                $.each( data.pending_files, function(index,  filename  ) {
                    index = index + 1;
                    var transactionFile = new File(filename, filename, index);
                    fileObjs.push(transactionFile);
                    var spanFile = "<span class='glyphicon glyphicon-level-up'></span>";
    django_collect_offline/static/django_offline/js/file_transfer.js on lines 83..89

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

    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

                $.each( data.pending_files, function( index,  filename  ) {
                    index = index + 1;
                    var txFile = new File(filename, filename, index);
                    fileObjs.push(txFile);
                    var spanFile = "<span class='glyphicon glyphicon-level-up'></span>";
    django_collect_offline/static/django_offline/js/file_transfer.js on lines 269..275

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

    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

    Severity: Major
    Found in django_collect_offline/models/server.py and 1 other location - About 2 hrs to fix
    django_collect_offline/models/client.py on lines 0..21

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

    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

    Severity: Major
    Found in django_collect_offline/models/client.py and 1 other location - About 2 hrs to fix
    django_collect_offline/models/server.py on lines 0..20

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

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

    function processOutgoingTransactions( host, userName ) {
        /* 
        Process each OutgoingTransaction one at a time.
        Requests are chained: 
            1. GET outgoingtransaction from host;
    Severity: Major
    Found in django_collect_offline/static/django_offline/js/edc_sync.js - About 2 hrs to fix

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

          $.ajaxSetup({
          beforeSend: function(xhr, settings) {
              if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                  xhr.setRequestHeader("X-CSRFToken", csrftoken);
              };
      Severity: Major
      Found in django_collect_offline/static/django_offline/js/middleman.js and 1 other location - About 2 hrs to fix
      django_collect_offline/static/django_offline/js/file_transfer.js on lines 12..19

      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

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

          $.ajaxSetup({
          beforeSend: function(xhr, settings) {
              if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                  xhr.setRequestHeader("X-CSRFToken", csrftoken);
              };
      django_collect_offline/static/django_offline/js/middleman.js on lines 13..20

      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

      Function processIncomingTransactions has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function processIncomingTransactions( homeUrl, userName ) {
          /*
          Process each IncomingTransaction one at a time.
          Requests are chained: 
              1. GET incoming from server;
      Severity: Minor
      Found in django_collect_offline/static/django_offline/js/edc_sync.js - About 1 hr to fix

        Function processPendingFiles has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function processPendingFiles() {
            var url = client + '/django_collect_offline/';
            var ajPendingFiles = $.ajax({
                url: url,
                type: 'GET',
        Severity: Minor
        Found in django_collect_offline/static/django_offline/js/file_transfer.js - About 1 hr to fix

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

              ajPatchOutgoing.fail(function( jqXHR, textStatus, errorThrown ) {
                  console.log( textStatus + ': ' + errorThrown + '(on PATCH)');
                  $( '#id-resource-alert-text' ).text( 'Done. Host ' + host + '.');
              });
          Severity: Major
          Found in django_collect_offline/static/django_offline/js/edc_sync.js and 1 other location - About 1 hr to fix
          django_collect_offline/static/django_offline/js/edc_sync.js on lines 118..121

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

          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

              ajPostIncoming.fail( function( jqXHR, textStatus, errorThrown ) {
                  console.log( textStatus + ': ' + errorThrown + '(on POST)' );
                  $( '#id-resource-alert-text' ).text( 'Done. Host ' + host + '.');
              });
          Severity: Major
          Found in django_collect_offline/static/django_offline/js/edc_sync.js and 1 other location - About 1 hr to fix
          django_collect_offline/static/django_offline/js/edc_sync.js on lines 123..126

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

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

          function exportBatch(server , userName) {
              var url = client + '/django_collect_offline/';
              var ajExportBatch = $.ajax({
                  url: url,
                  type: 'GET',
          Severity: Minor
          Found in django_collect_offline/static/django_offline/js/file_transfer.js - About 1 hr to fix

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

            function loadUsbTransactionFile(server , userName) {
                var url = client + '/django_collect_offline/dump-to-usb/';
                var ajloadFile = $.ajax({
                    url: url,
                    type: 'GET',
            Severity: Minor
            Found in django_collect_offline/static/django_offline/js/middleman.js - About 1 hr to fix

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

              class TestOfflineModelNoHistoryManager(BaseUuidModel):
                  """A test model without a HistoricalManager.
                  """
              
                  f1 = models.CharField(max_length=50, default="f1")
              Severity: Major
              Found in collect_offline_app/models.py and 1 other location - About 1 hr to fix
              collect_offline_app/models.py on lines 92..101

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

                  def register(self, models=None, wrapper_cls=None):
                      """Registers with app_label.modelname, wrapper_cls.
                      """
                      if get_offline_enabled():
                          self.loaded = True
              Severity: Minor
              Found in django_collect_offline/site_offline_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 autodiscover has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def autodiscover(self, module_name=None):
                      module_name = module_name or self.module_name
                      sys.stdout.write(" * checking for models to register ...\n")
                      for app in django_apps.app_configs:
                          try:
              Severity: Minor
              Found in django_collect_offline/site_offline_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

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

              class TestOfflineModelNoUuid(BaseModel):
                  """A test model without a HistoricalManager.
                  """
              
                  f1 = models.CharField(max_length=50, default="f1")
              Severity: Major
              Found in collect_offline_app/models.py and 1 other location - About 1 hr to fix
              collect_offline_app/models.py on lines 80..89

              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

              Severity
              Category
              Status
              Source
              Language