ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
B
5 hrs
Test Coverage
F
30%

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

  def textual_base_snapshot
    base_snapshot = @record.base_snapshot if @record.respond_to?(:base_snapshot)
    h = {
      :label => _('Base Snapshot'),
      :icon  => "fa fa-camera",
Severity: Major
Found in app/helpers/cloud_volume_helper/textual_summary.rb and 3 other locations - About 55 mins to fix
app/helpers/cloud_volume_helper/textual_summary.rb on lines 98..105
app/helpers/cloud_volume_snapshot_helper/textual_summary.rb on lines 40..47
app/helpers/vm_helper/textual_summary.rb on lines 439..446

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

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

  def textual_cloud_tenant
    cloud_tenant = @record.cloud_tenant if @record.respond_to?(:cloud_tenant)
    h = {:label => _('Cloud Tenants'), :icon => "pficon pficon-cloud-tenant", :value => (cloud_tenant.nil? ? _("None") : cloud_tenant.name)}
    if cloud_tenant && role_allows?(:feature => "cloud_tenant_show")
      h[:title] = _("Show this Volume's Cloud Tenants")
Severity: Major
Found in app/helpers/cloud_volume_helper/textual_summary.rb and 3 other locations - About 55 mins to fix
app/helpers/cloud_volume_helper/textual_summary.rb on lines 84..95
app/helpers/cloud_volume_snapshot_helper/textual_summary.rb on lines 40..47
app/helpers/vm_helper/textual_summary.rb on lines 439..446

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

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

  def textual_availability_zone
    availability_zone = @record.availability_zone
    h = {
      :label => _('Availability Zone'),
      :icon  => "pficon pficon-zone",
Severity: Major
Found in app/helpers/cloud_volume_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/host_helper/textual_summary.rb on lines 274..281
app/helpers/service_helper/textual_summary.rb on lines 153..160
app/helpers/vm_helper/textual_summary.rb on lines 248..255
app/helpers/vm_helper/textual_summary.rb on lines 289..298
app/helpers/vm_helper/textual_summary.rb on lines 301..308
app/helpers/vm_helper/textual_summary.rb on lines 311..318

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

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_host_initiators
    num   = @record.number_of(:host_initiators)
    h     = {:label => _('Host Initiators'), :value => num, :icon => "pficon pficon-volume"}
    if num > 0 && role_allows?(:feature => "host_initiator_show_list")
      h[:title] = _("Show host initiators mapped to this volume")
Severity: Minor
Found in app/helpers/cloud_volume_helper/textual_summary.rb and 2 other locations - About 40 mins to fix
app/helpers/host_initiator_group_helper/textual_summary.rb on lines 60..67
app/helpers/host_initiator_helper/textual_summary.rb on lines 54..61

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

  def textual_cloud_volume_snapshots
    num   = @record.number_of(:cloud_volume_snapshots)
    h     = {:label => _('Cloud Volume Snapshots'), :icon => "fa fa-camera", :value => num}
    if num > 0 && role_allows?(:feature => "cloud_volume_snapshot_show_list")
      h[:title] = _("Show all Cloud Volume Snapshots")
Severity: Major
Found in app/helpers/cloud_volume_helper/textual_summary.rb and 3 other locations - About 40 mins to fix
app/helpers/cloud_object_store_container_helper/textual_summary.rb on lines 40..47
app/helpers/cloud_volume_helper/textual_summary.rb on lines 118..125
app/helpers/cloud_volume_helper/textual_summary.rb on lines 128..135

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

  def textual_cloud_volume_backups
    num   = @record.number_of(:cloud_volume_backups)
    h     = {:label => _('Cloud Volume Backups'), :icon => "pficon pficon-volume", :value => num}
    if num > 0 && role_allows?(:feature => "cloud_volume_backup_show_list")
      h[:title] = _("Show all Cloud Volume Backups")
Severity: Major
Found in app/helpers/cloud_volume_helper/textual_summary.rb and 3 other locations - About 40 mins to fix
app/helpers/cloud_object_store_container_helper/textual_summary.rb on lines 40..47
app/helpers/cloud_volume_helper/textual_summary.rb on lines 108..115
app/helpers/cloud_volume_helper/textual_summary.rb on lines 128..135

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

  def textual_attachments
    num   = @record.number_of(:attachments)
    h     = {:label => _('Instances'), :icon => "pficon pficon-virtual-machine", :value => num}
    if num > 0 && role_allows?(:feature => "vm_show_list")
      h[:title] = _("Show all attached Instances")
Severity: Major
Found in app/helpers/cloud_volume_helper/textual_summary.rb and 3 other locations - About 40 mins to fix
app/helpers/cloud_object_store_container_helper/textual_summary.rb on lines 40..47
app/helpers/cloud_volume_helper/textual_summary.rb on lines 108..115
app/helpers/cloud_volume_helper/textual_summary.rb on lines 118..125

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