axsh/wakame-vdc

View on GitHub
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js

Summary

Maintainability
F
6 days
Test Coverage

Function networkPanel has 333 lines of code (exceeds 25 allowed). Consider refactoring.
Open

DcmgrGUI.prototype.networkPanel = function(){
  var total = 0;
  var maxrow = 10;
  var page = 1;
  var list_request = { 
Severity: Major
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 1 day to fix

Function callback has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      callback: function(){
        var self = this;

        var network_id = $(this).find('#network_id').val();
        var display_name = $(this).find('#network_display_name').val();
Severity: Major
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 4 hrs to fix

File network_panel.js has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

DcmgrGUI.prototype.networkPanel = function(){
  var total = 0;
  var maxrow = 10;
  var page = 1;
  var list_request = { 
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 4 hrs to fix

Function callback has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    callback: function(){
      var self = this;

      var request = new DcmgrGUI.Request;
      var is_ready = {
Severity: Major
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 2 hrs to fix

Function networkPanel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

DcmgrGUI.prototype.networkPanel = function(){
  var total = 0;
  var maxrow = 10;
  var page = 1;
  var list_request = { 
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.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 refresh_network_services has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        var refresh_network_services = function() {
          request.get({
            "url": '/networks/'+ network_id +'/services.json',
            "data": "",
            success: function(json,status){
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 1 hr to fix

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

            success: function(json,status){
              var create_select_item = function(name) {
                var select_html = '<select id="' + name + '" name="' + name + '"></select>';
                $(self).find('#select_' + name).empty().html(select_html);
                return $(self).find('#' + name);
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 1 hr to fix

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

  create_network_buttons[create_button_name] = function() {
    var display_name = $(this).find('#display_name').val();
    var description = $(this).find('#description').val();
    var domain_name = $(this).find('#domain_name').val();
    var dc_network = $(this).find('#dc_network').val();
Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 1 hr to fix

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

            success: function(json,status){
              var results = json[0].network_service.results;
              var network_services = $(self).find('#network_services');
              network_services.html('');

Severity: Minor
Found in frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js - About 1 hr to fix

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

  bt_refresh.element.bind('dcmgrGUI.refresh',function(){
    c_list.page = c_pagenate.current_page;
    list_request.url = DcmgrGUI.Util.getPagePath('/networks/list/',c_list.page);
    list_request.data = DcmgrGUI.Util.getPagenateData(c_pagenate.start,c_pagenate.row);
    c_list.element.trigger('dcmgrGUI.updateList',{request:list_request})
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/backup_panel.js on lines 203..215
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/host_node_panel.js on lines 59..72
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/storage_node_panel.js on lines 61..74
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/volume_panel.js on lines 360..373

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

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 3 locations. Consider refactoring.
Open

  c_list.filter.add(function(data){
    var results = data.network.results;
    var size = results.length;
    for(var i = 0; i < size; i++) {
      results[i].result.created_at = DcmgrGUI.date.parseISO8601(results[i].result.created_at);
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/backup_panel.js on lines 106..115
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/volume_panel.js on lines 106..115

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

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

              var create_select_item = function(name) {
                var select_html = '<select id="' + name + '" name="' + name + '"></select>';
                $(self).find('#select_' + name).empty().html(select_html);
                return $(self).find('#' + name);
              }
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/image_panel.js on lines 385..389

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

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

      var ready = function(data) {
        if(data['dc_network'] == true &&
           data['display_name'] == true) {  
          bt_create_network.disabledButton(1, false);
        } else {
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/volume_panel.js on lines 159..166

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

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

    var data = "&display_name="+display_name
          +"&description="+description
          +"&domain_name="+domain_name
          +"&dc_network="+dc_network
          +"&network_mode="+network_mode
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/resource_manage_panel.js on lines 348..355

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

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

          request.del({
            "url": '/networks/' + network_id + '/services',
            "data": data,
            success: function(json,status){
              refresh_network_services();
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js on lines 207..213

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

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

          request.post({
            "url": '/networks/'+ network_id +'/services.json',
            "data": data,
            success: function(json,status) {
              refresh_network_services();
frontend/dcmgr_gui/public/javascripts/dcmgr_gui/network_panel.js on lines 184..190

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

There are no issues that match your filters.

Category
Status