ManageIQ/manageiq-ui-classic

View on GitHub
app/helpers/storage_helper/textual_summary.rb

Summary

Maintainability
B
6 hrs
Test Coverage
F
57%

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

  def textual_hosts
    label = _("Hosts")
    num   = @record.number_of(:hosts)
    h     = {:label => label, :icon => "pficon pficon-container-node", :value => num}
    if num.positive? && role_allows?(:feature => "host_show_list")
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 2 other locations - About 50 mins to fix
app/helpers/cloud_subnet_helper/textual_summary.rb on lines 96..104
app/helpers/storage_helper/textual_summary.rb on lines 86..94

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

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

  def textual_managed_vms
    label = _("Managed VMs")
    num   = @record.number_of(:all_vms)
    h     = {:label => label, :icon => "pficon pficon-virtual-machine", :value => num}
    if num.positive? && role_allows?(:feature => "vm_show_list")
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 2 other locations - About 50 mins to fix
app/helpers/cloud_subnet_helper/textual_summary.rb on lines 96..104
app/helpers/storage_helper/textual_summary.rb on lines 75..83

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

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 textual_managed_miq_templates
    num   = @record.number_of(:all_miq_templates)
    h     = {:label => _("Managed VM Templates"), :icon => "pficon pficon-virtual-machine", :value => num}
    if num.positive? && role_allows?(:feature => "miq_template_show_list")
      h[:link]  = url_for_only_path(:action => 'show', :id => @record, :display => 'all_miq_templates')
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 7 other locations - About 35 mins to fix
app/helpers/cloud_subnet_helper/textual_summary.rb on lines 70..77
app/helpers/flavor_helper/textual_summary.rb on lines 75..82
app/helpers/host_aggregate_helper/textual_summary.rb on lines 16..23
app/helpers/host_aggregate_helper/textual_summary.rb on lines 26..33
app/helpers/network_router_helper/textual_summary.rb on lines 72..79
app/helpers/orchestration_stack_helper/textual_summary.rb on lines 90..97
app/helpers/placement_group_helper/textual_summary.rb on lines 29..36

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

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

  def textual_vm_misc_files
    value = textual_format_used_space(
      @record.v_total_vm_misc_size,
      @record.v_vm_misc_percent_of_used,
      num = @record.number_of(:vm_misc_files)
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/storage_helper/textual_summary.rb on lines 161..172
app/helpers/storage_helper/textual_summary.rb on lines 175..186
app/helpers/storage_helper/textual_summary.rb on lines 189..200
app/helpers/storage_helper/textual_summary.rb on lines 217..228

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

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

  def textual_disk_files
    value = textual_format_used_space(
      @record.v_total_disk_size,
      @record.v_disk_percent_of_used,
      num = @record.number_of(:disk_files)
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/storage_helper/textual_summary.rb on lines 175..186
app/helpers/storage_helper/textual_summary.rb on lines 189..200
app/helpers/storage_helper/textual_summary.rb on lines 203..214
app/helpers/storage_helper/textual_summary.rb on lines 217..228

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

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

  def textual_debris_files
    value = textual_format_used_space(
      @record.v_total_debris_size,
      @record.v_debris_percent_of_used,
      num = @record.number_of(:debris_files)
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/storage_helper/textual_summary.rb on lines 161..172
app/helpers/storage_helper/textual_summary.rb on lines 175..186
app/helpers/storage_helper/textual_summary.rb on lines 189..200
app/helpers/storage_helper/textual_summary.rb on lines 203..214

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

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

  def textual_vm_ram_files
    value = textual_format_used_space(
      @record.v_total_memory_size,
      @record.v_memory_percent_of_used,
      num = @record.number_of(:vm_ram_files)
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/storage_helper/textual_summary.rb on lines 161..172
app/helpers/storage_helper/textual_summary.rb on lines 175..186
app/helpers/storage_helper/textual_summary.rb on lines 203..214
app/helpers/storage_helper/textual_summary.rb on lines 217..228

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

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

  def textual_snapshot_files
    value = textual_format_used_space(
      @record.v_total_snapshot_size,
      @record.v_snapshot_percent_of_used,
      num = @record.number_of(:snapshot_files)
Severity: Major
Found in app/helpers/storage_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/storage_helper/textual_summary.rb on lines 161..172
app/helpers/storage_helper/textual_summary.rb on lines 189..200
app/helpers/storage_helper/textual_summary.rb on lines 203..214
app/helpers/storage_helper/textual_summary.rb on lines 217..228

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

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 textual_registered_vms
    value = @record.total_managed_registered_vms
    h = {:label => _("Managed/Registered VMs"),
         :icon  => "pficon pficon-virtual-machine",
         :value => value}
Severity: Minor
Found in app/helpers/storage_helper/textual_summary.rb and 1 other location - About 35 mins to fix
app/helpers/storage_helper/textual_summary.rb on lines 119..128

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

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 textual_unregistered_vms
    value = @record.total_unregistered_vms
    h = {:label => _("Managed/Unregistered VMs"),
         :icon  => "pficon pficon-virtual-machine",
         :value => value}
Severity: Minor
Found in app/helpers/storage_helper/textual_summary.rb and 1 other location - About 35 mins to fix
app/helpers/storage_helper/textual_summary.rb on lines 107..116

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

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

  def textual_custom_button_events
    return nil unless User.current_user.super_admin_user? || User.current_user.admin?

    {
      :label => _('Custom Button Events'),
Severity: Minor
Found in app/helpers/storage_helper/textual_summary.rb and 1 other location - About 30 mins to fix
app/helpers/service_helper/textual_summary.rb on lines 294..301

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

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