Katello/katello

View on GitHub
app/assets/javascripts/katello/sync_management/sync_management.js

Summary

Maintainability
F
4 days
Test Coverage

Function content has 206 lines of code (exceeds 25 allowed). Consider refactoring.
Open

KT.content = (function () {
  var draw_syncing = function (repo_id, progress, task_id) {
      var element = $("#repo-" + repo_id).find(".result"),
        cancelButton = $("<a/>").attr("class", "cancel_sync").text(katelloI18n.cancel),
        progressBar = $("<a/>").attr("class", "progress").text(" ");
Severity: Major
Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 1 day to fix

    Function content has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    KT.content = (function () {
      var draw_syncing = function (repo_id, progress, task_id) {
          var element = $("#repo-" + repo_id).find(".result"),
            cancelButton = $("<a/>").attr("class", "cancel_sync").text(katelloI18n.cancel),
            progressBar = $("<a/>").attr("class", "progress").text(" ");
    Severity: Minor
    Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 5 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

    File sync_management.js has 371 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    KT.content = (function () {
      var draw_syncing = function (repo_id, progress, task_id) {
          var element = $("#repo-" + repo_id).find(".result"),
            cancelButton = $("<a/>").attr("class", "cancel_sync").text(katelloI18n.cancel),
            progressBar = $("<a/>").attr("class", "progress").text(" ");
    Severity: Minor
    Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 4 hrs to fix

      Function content_actions has 114 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      KT.content_actions = (function () {
        var syncing = [],
          updater,
          getOrg = function () {
            return $("#organization_id").val();
      Severity: Major
      Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 4 hrs to fix

        Function startUpdater has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            startUpdater = function () {
              if (syncing.length === 0) {
                return;
              }
              var url = tfm.tools.foremanUrl("/katello/sync_management/sync_status");
        Severity: Major
        Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 2 hrs to fix

          Function content_actions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          KT.content_actions = (function () {
            var syncing = [],
              updater,
              getOrg = function () {
                return $("#organization_id").val();
          Severity: Minor
          Found in app/assets/javascripts/katello/sync_management/sync_management.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 updateProduct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              updateProduct = function (prod_id, done, percent, size) {
                var product_element = $("#product-" + prod_id),
                  element = product_element.find(".result"),
                  oldpg = element.find(".progress");
          
          
          Severity: Minor
          Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 1 hr to fix

            Function updateRepo has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  repo_id,
                  starttime,
                  duration,
                  progress,
                  display_size,
            Severity: Major
            Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 1 hr to fix

              Function update_item has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    element,
                    starttime,
                    duration,
                    progress,
                    display_size,
              Severity: Major
              Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 1 hr to fix

                Function finishRepo has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    finishRepo = function (repo_id, state, duration, raw_state, error_details, task_id) {
                Severity: Minor
                Found in app/assets/javascripts/katello/sync_management/sync_management.js - About 45 mins to fix

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

                                KT.content.updateRepo(
                                  repo.id,
                                  repo.start_time,
                                  repo.duration,
                                  repo.progress.progress,
                  app/assets/javascripts/katello/sync_management/sync_management.js on lines 298..307

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

                  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

                                KT.content.updateRepo(
                                  repo.id,
                                  repo.start_time,
                                  repo.duration,
                                  repo.progress.progress,
                  app/assets/javascripts/katello/sync_management/sync_management.js on lines 318..327

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

                  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

                        $("#products_table")
                          .find("tr")
                          .removeClass("collapsed")
                          .addClass("expanded")
                          .each(function () {
                  app/assets/javascripts/katello/sync_management/sync_management.js on lines 200..206

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

                  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

                        $("#products_table")
                          .find("tr")
                          .removeClass("expanded")
                          .addClass("collapsed")
                          .each(function () {
                  app/assets/javascripts/katello/sync_management/sync_management.js on lines 191..197

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

                  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