axsh/wakame-vdc

View on GitHub
frontend/dcmgr_gui/app/controllers/volumes_controller.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    catch_error do
      backup_object_ids = params[:ids]
      display_name = params[:display_name]
      if backup_object_ids
Severity: Minor
Found in frontend/dcmgr_gui/app/controllers/volumes_controller.rb - About 1 hr to fix

Method create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    catch_error do
      backup_object_ids = params[:ids]
      display_name = params[:display_name]
      if backup_object_ids
Severity: Minor
Found in frontend/dcmgr_gui/app/controllers/volumes_controller.rb - About 25 mins 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 4 locations. Consider refactoring.
Open

  def total
    catch_error do
      all_resource_count = Hijiki::DcmgrResource::Volume.total_resource
      all_resources = Hijiki::DcmgrResource::Volume.find(:all,:params => {:start => 0, :limit => all_resource_count})
      resources = all_resources[0].results
Severity: Major
Found in frontend/dcmgr_gui/app/controllers/volumes_controller.rb and 3 other locations - About 50 mins to fix
frontend/dcmgr_gui/app/controllers/backups_controller.rb on lines 49..57
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 188..196
frontend/dcmgr_gui/app/controllers/load_balancers_controller.rb on lines 56..64

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

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

  def list
    catch_error do
      data = {
        :start => params[:start].to_i - 1,
        :limit => params[:limit]
Severity: Major
Found in frontend/dcmgr_gui/app/controllers/volumes_controller.rb and 7 other locations - About 30 mins to fix
frontend/dcmgr_gui/app/controllers/backups_controller.rb on lines 19..26
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 66..73
frontend/dcmgr_gui/app/controllers/load_balancers_controller.rb on lines 45..52
frontend/dcmgr_gui/app/controllers/machine_images_controller.rb on lines 15..22
frontend/dcmgr_gui/app/controllers/network_vifs_controller.rb on lines 14..21
frontend/dcmgr_gui/app/controllers/networks_controller.rb on lines 38..45
frontend/dcmgr_gui/app/controllers/storage_nodes_controller.rb on lines 7..14

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

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

  def destroy
    catch_error do
      volume_ids = params[:ids]
      res = []
      volume_ids.each do |volume_id|
Severity: Major
Found in frontend/dcmgr_gui/app/controllers/volumes_controller.rb and 8 other locations - About 15 mins to fix
frontend/dcmgr_gui/app/controllers/backups_controller.rb on lines 8..16
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 85..93
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 96..104
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 107..115
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 118..126
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 141..149
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 152..160
frontend/dcmgr_gui/app/controllers/volumes_controller.rb on lines 100..108

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

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 update
    catch_error do
      volume_id = params[:id]
      data = {
        :display_name => params[:display_name]
Severity: Minor
Found in frontend/dcmgr_gui/app/controllers/volumes_controller.rb and 1 other location - About 15 mins to fix
frontend/dcmgr_gui/app/controllers/backups_controller.rb on lines 38..46

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

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

  def detach
    catch_error do
      volume_ids = params[:ids]
      res = []
      volume_ids.each do |volume_id|
Severity: Major
Found in frontend/dcmgr_gui/app/controllers/volumes_controller.rb and 8 other locations - About 15 mins to fix
frontend/dcmgr_gui/app/controllers/backups_controller.rb on lines 8..16
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 85..93
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 96..104
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 107..115
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 118..126
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 141..149
frontend/dcmgr_gui/app/controllers/instances_controller.rb on lines 152..160
frontend/dcmgr_gui/app/controllers/volumes_controller.rb on lines 43..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 26.

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