ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
A
3 hrs
Test Coverage
A
90%

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

  def textual_storage_managers
    num   = @record.try(:storage_managers) ? @record.number_of(:storage_managers) : 0
    h     = {:label => _('Storage Managers'), :icon => "fa fa-database", :value => num}
    if num.positive? && role_allows?(:feature => "ems_storage_show_list")
      h[:title] = _("Show all Storage Managers")
Severity: Minor
Found in app/helpers/ems_cloud_helper/textual_summary.rb and 1 other location - About 45 mins to fix
app/helpers/ems_cloud_helper/textual_summary.rb on lines 134..141

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

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_databases
    num   = @record.try(:cloud_databases) ? @record.number_of(:cloud_databases) : 0
    h     = {:label => _('Cloud Databases'), :icon => "fa fa-database", :value => num}
    if num.positive? && role_allows?(:feature => "cloud_database_show_list")
      h[:title] = _("Show all Cloud Databases")
Severity: Minor
Found in app/helpers/ems_cloud_helper/textual_summary.rb and 1 other location - About 45 mins to fix
app/helpers/ems_cloud_helper/textual_summary.rb on lines 114..121

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

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_images
    num = @record.number_of(:miq_templates)
    h = {:label => _('Images'), :icon => "pficon pficon-virtual-machine", :value => num}
    if num.positive? && role_allows?(:feature => "miq_template_show_list")
      h[:link] = ems_cloud_path(@record.id, :display => 'images')
Severity: Major
Found in app/helpers/ems_cloud_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/ems_cloud_helper/textual_summary.rb on lines 76..83
app/helpers/ems_cloud_helper/textual_summary.rb on lines 96..103
app/helpers/ems_cloud_helper/textual_summary.rb on lines 164..171
app/helpers/ems_container_helper/textual_summary.rb on lines 72..79

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

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_instances
    num   = @record.number_of(:vms)
    h     = {:label => _('Instances'), :icon => "pficon pficon-virtual-machine", :value => num}
    if num.positive? && role_allows?(:feature => "vm_show_list")
      h[:link]  = ems_cloud_path(@record.id, :display => 'instances')
Severity: Major
Found in app/helpers/ems_cloud_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/ems_cloud_helper/textual_summary.rb on lines 86..93
app/helpers/ems_cloud_helper/textual_summary.rb on lines 96..103
app/helpers/ems_cloud_helper/textual_summary.rb on lines 164..171
app/helpers/ems_container_helper/textual_summary.rb on lines 72..79

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

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_security_groups
    num = @record.number_of(:security_groups)
    h = {:label => _('Security Groups'), :icon => "pficon pficon-cloud-security", :value => num}
    if num.positive? && role_allows?(:feature => "security_group_show_list")
      h[:link] = ems_cloud_path(@record.id, :display => 'security_groups')
Severity: Major
Found in app/helpers/ems_cloud_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/ems_cloud_helper/textual_summary.rb on lines 76..83
app/helpers/ems_cloud_helper/textual_summary.rb on lines 86..93
app/helpers/ems_cloud_helper/textual_summary.rb on lines 96..103
app/helpers/ems_container_helper/textual_summary.rb on lines 72..79

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

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_cloud_volumes
    num = @record.number_of(:cloud_volumes)
    h = {:label => _('Cloud Volumes'), :icon => "pficon pficon-volume", :value => num}
    if num.positive? && role_allows?(:feature => "cloud_volume_show_list")
      h[:link] = ems_cloud_path(@record.id, :display => 'cloud_volumes')
Severity: Major
Found in app/helpers/ems_cloud_helper/textual_summary.rb and 4 other locations - About 35 mins to fix
app/helpers/ems_cloud_helper/textual_summary.rb on lines 76..83
app/helpers/ems_cloud_helper/textual_summary.rb on lines 86..93
app/helpers/ems_cloud_helper/textual_summary.rb on lines 164..171
app/helpers/ems_container_helper/textual_summary.rb on lines 72..79

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

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