ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
A
3 hrs
Test Coverage
C
79%

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

  def textual_cloud_volumes
    label = _('Volumes')
    num   = @record.number_of(:cloud_volumes)
    h     = {:label => label, :icon => "pficon pficon-volume", :value => num}
    if num > 0 && role_allows?(:feature => "cloud_volume_show_list")
Severity: Minor
Found in app/helpers/cloud_tenant_helper/textual_summary.rb and 1 other location - About 50 mins to fix
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 85..93

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

  def textual_cloud_volume_snapshots
    label = _('Volume Snapshots')
    num   = @record.number_of(:cloud_volume_snapshots)
    h     = {:label => label, :icon => "fa fa-camera", :value => num}
    if num > 0 && role_allows?(:feature => "cloud_volume_snapshot_show_list")
Severity: Minor
Found in app/helpers/cloud_tenant_helper/textual_summary.rb and 1 other location - About 50 mins to fix
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 74..82

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

  def textual_instances
    num   = @record.number_of(:vms)
    h     = {:label => _('Instances'), :icon => "pficon pficon-virtual-machine", :value => num}
    if num > 0 && role_allows?(:feature => "vm_show_list")
      h[:link]  = url_for_only_path(:action => 'show', :id => @record, :display => 'instances')
Severity: Major
Found in app/helpers/cloud_tenant_helper/textual_summary.rb and 9 other locations - About 40 mins to fix
app/helpers/auth_key_pair_cloud_helper/textual_summary.rb on lines 26..33
app/helpers/availability_zone_helper/textual_summary.rb on lines 21..28
app/helpers/availability_zone_helper/textual_summary.rb on lines 31..38
app/helpers/cloud_network_helper/textual_summary.rb on lines 42..49
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 52..59
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 96..103
app/helpers/security_group_helper/textual_summary.rb on lines 67..74
app/helpers/security_policy_rule_helper/textual_summary.rb on lines 119..126
app/helpers/security_policy_rule_helper/textual_summary.rb on lines 133..140

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

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

  def textual_images
    num   = @record.number_of(:miq_templates)
    h     = {:label => _('Images'), :icon => "pficon pficon-virtual-machine", :value => num}
    if num > 0 && role_allows?(:feature => "miq_template_show_list")
      h[:link]  = url_for_only_path(:action => 'show', :id => @record, :display => 'images')
Severity: Major
Found in app/helpers/cloud_tenant_helper/textual_summary.rb and 9 other locations - About 40 mins to fix
app/helpers/auth_key_pair_cloud_helper/textual_summary.rb on lines 26..33
app/helpers/availability_zone_helper/textual_summary.rb on lines 21..28
app/helpers/availability_zone_helper/textual_summary.rb on lines 31..38
app/helpers/cloud_network_helper/textual_summary.rb on lines 42..49
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 42..49
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 96..103
app/helpers/security_group_helper/textual_summary.rb on lines 67..74
app/helpers/security_policy_rule_helper/textual_summary.rb on lines 119..126
app/helpers/security_policy_rule_helper/textual_summary.rb on lines 133..140

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

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

  def textual_cloud_object_store_containers
    num   = @record.number_of(:cloud_object_store_containers)
    h     = {:label => _('Cloud Object Store Containers'), :icon => "ff ff-cloud-object-store", :value => num}
    if num > 0 && role_allows?(:feature => "cloud_object_store_container_show_list")
      h[:link]  = url_for_only_path(:action => 'show', :id => @record, :display => 'cloud_object_store_containers')
Severity: Major
Found in app/helpers/cloud_tenant_helper/textual_summary.rb and 9 other locations - About 40 mins to fix
app/helpers/auth_key_pair_cloud_helper/textual_summary.rb on lines 26..33
app/helpers/availability_zone_helper/textual_summary.rb on lines 21..28
app/helpers/availability_zone_helper/textual_summary.rb on lines 31..38
app/helpers/cloud_network_helper/textual_summary.rb on lines 42..49
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 42..49
app/helpers/cloud_tenant_helper/textual_summary.rb on lines 52..59
app/helpers/security_group_helper/textual_summary.rb on lines 67..74
app/helpers/security_policy_rule_helper/textual_summary.rb on lines 119..126
app/helpers/security_policy_rule_helper/textual_summary.rb on lines 133..140

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

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