ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
D
2 days
Test Coverage
C
79%

File textual_summary.rb has 519 lines of code (exceeds 400 allowed). Consider refactoring.
Open

module VmHelper::TextualSummary
  include TextualMixins::TextualAdvancedSettings
  include TextualMixins::TextualDescription
  include TextualMixins::TextualDrift
  include TextualMixins::TextualFilesystems
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb - About 4 hrs to fix

Method textual_storage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def textual_storage
    storages = @record.storages
    h = {:label => _('Datastores'), :icon => "fa fa-database"}
    if storages.empty?
      h[:value] = _("None")
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.rb - About 35 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

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

  def textual_usage_overcommitted
    h = {:label => _("Unused/Overcommited Allocation")}
    value = @record.uncommitted_storage
    h[:title] = value.nil? ? _("N/A") : "#{number_with_delimiter(value)} bytes"
    h[:value] = if value.nil?
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.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

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

  def textual_container
    h = {:label => _("Container")}
    vendor = @record.vendor
    if vendor.blank?
      h[:value] = _("None")
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.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 2 locations. Consider refactoring.
Open

  def textual_normal_operating_ranges_cpu_usage
    h = {:label => _("CPU Usage"), :value => []}
    [:max, _("Max"), :high, _("High"), :avg, _("Average"), :low, _("Low")].each_slice(2) do |key, label|
      value = @record.send("cpu_usage_rate_average_#{key}_over_time_period")
      h[:value] << {:label => label,
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 1 other location - About 1 hr to fix
app/helpers/vm_helper/textual_summary.rb on lines 585..592

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

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_normal_operating_ranges_memory_usage
    h = {:label => _("Memory Usage"), :value => []}
    [:max, _("Max"), :high, _("High"), :avg, _("Average"), :low, _("Low")].each_slice(2) do |key, label|
      value = @record.send("mem_usage_absolute_average_#{key}_over_time_period")
      h[:value] << {:label => label,
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 1 other location - About 1 hr to fix
app/helpers/vm_helper/textual_summary.rb on lines 565..572

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

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_orchestration_stack
    stack = @record.orchestration_stack
    h = {:label => _('Orchestration Stack'), :icon => "ff ff-stack", :value => (stack.nil? ? _("None") : stack.name)}
    if stack && role_allows?(:feature => "orchestration_stack_show")
      h[:title] = _("Show this VM's Orchestration Stack '%{name}'") % {:name => stack.name}
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 2 other locations - About 55 mins to fix
app/helpers/resource_pool_helper/textual_summary.rb on lines 82..91
app/helpers/resource_pool_helper/textual_summary.rb on lines 94..103

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

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 VM's Cloud Tenants")
Severity: Major
Found in app/helpers/vm_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_helper/textual_summary.rb on lines 98..105
app/helpers/cloud_volume_snapshot_helper/textual_summary.rb on lines 40..47

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_vm_template
    vm_template = @record.genealogy_parent
    h = {:label => _('VM Template'), :icon => "pficon pficon-template", :value => (vm_template.nil? ? _("None") : vm_template.name)}
    if vm_template && role_allows?(:feature => "miq_template_show")
      h[:title] = _("Show this VM's Template")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/cloud_volume_helper/textual_summary.rb on lines 70..81
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

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

  def textual_availability_zone
    availability_zone = @record.availability_zone
    h = {:label => _('Availability Zone'),
         :icon  => "pficon pficon-zone",
         :value => (availability_zone.nil? ? _("None") : availability_zone.name)}
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/cloud_volume_helper/textual_summary.rb on lines 70..81
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 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 7 locations. Consider refactoring.
Open

  def textual_resource_pool
    rp = @record.parent_resource_pool
    h = {:label => _("Resource Pool"), :icon => "pficon pficon-resource-pool", :value => (rp.nil? ? _("None") : rp.name)}
    if rp && role_allows?(:feature => "resource_pool_show")
      h[:title] = _("Show this VM's Resource Pool")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/cloud_volume_helper/textual_summary.rb on lines 70..81
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 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 7 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[:title] = _("Show all Security Groups")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 371..379
app/helpers/vm_helper/textual_summary.rb on lines 382..390
app/helpers/vm_helper/textual_summary.rb on lines 393..401
app/helpers/vm_helper/textual_summary.rb on lines 417..425
app/helpers/vm_helper/textual_summary.rb on lines 428..436
app/helpers/vm_helper/textual_summary.rb on lines 449..457

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

  def textual_network_routers
    num   = @record.number_of(:network_routers)
    h     = {:label => _('Network Routers'), :icon => "pficon pficon-route", :value => num}
    if num.positive? && role_allows?(:feature => "network_router_show_list")
      h[:title] = _("Show all Network Routers")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 360..368
app/helpers/vm_helper/textual_summary.rb on lines 371..379
app/helpers/vm_helper/textual_summary.rb on lines 393..401
app/helpers/vm_helper/textual_summary.rb on lines 417..425
app/helpers/vm_helper/textual_summary.rb on lines 428..436
app/helpers/vm_helper/textual_summary.rb on lines 449..457

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

  def textual_network_ports
    num   = @record.number_of(:network_ports)
    h     = {:label => _('Network Ports'), :icon => "ff ff-network-port", :value => num}
    if num.positive? && role_allows?(:feature => "network_port_show_list")
      h[:title] = _("Show all Network Ports")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 360..368
app/helpers/vm_helper/textual_summary.rb on lines 371..379
app/helpers/vm_helper/textual_summary.rb on lines 382..390
app/helpers/vm_helper/textual_summary.rb on lines 393..401
app/helpers/vm_helper/textual_summary.rb on lines 428..436
app/helpers/vm_helper/textual_summary.rb on lines 449..457

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

  def textual_cloud_networks
    num   = @record.number_of(:cloud_networks)
    h     = {:label => _('Cloud Networks'), :icon => "ff ff-cloud-network", :value => num}
    if num.positive? && role_allows?(:feature => "cloud_network_show_list")
      h[:title] = _("Show all Cloud Networks")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 360..368
app/helpers/vm_helper/textual_summary.rb on lines 371..379
app/helpers/vm_helper/textual_summary.rb on lines 382..390
app/helpers/vm_helper/textual_summary.rb on lines 393..401
app/helpers/vm_helper/textual_summary.rb on lines 417..425
app/helpers/vm_helper/textual_summary.rb on lines 449..457

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 7 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[:title]    = _("Show all Cloud Volumes attached to this VM.")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 360..368
app/helpers/vm_helper/textual_summary.rb on lines 371..379
app/helpers/vm_helper/textual_summary.rb on lines 382..390
app/helpers/vm_helper/textual_summary.rb on lines 393..401
app/helpers/vm_helper/textual_summary.rb on lines 417..425
app/helpers/vm_helper/textual_summary.rb on lines 428..436

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

  def textual_floating_ips
    num   = @record.number_of(:floating_ips)
    h     = {:label => _('Floating IPs'), :icon => "ff ff-floating-ip", :value => num}
    if num.positive? && role_allows?(:feature => "floating_ip_show_list")
      h[:title] = _("Show all Floating IPs")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 360..368
app/helpers/vm_helper/textual_summary.rb on lines 382..390
app/helpers/vm_helper/textual_summary.rb on lines 393..401
app/helpers/vm_helper/textual_summary.rb on lines 417..425
app/helpers/vm_helper/textual_summary.rb on lines 428..436
app/helpers/vm_helper/textual_summary.rb on lines 449..457

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

  def textual_cloud_subnets
    num   = @record.number_of(:cloud_subnets)
    h     = {:label => _('Cloud Subnets'), :icon => "pficon pficon-network", :value => num}
    if num.positive? && role_allows?(:feature => "cloud_subnet_show_list")
      h[:title] = _("Show all Cloud Subnets")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 360..368
app/helpers/vm_helper/textual_summary.rb on lines 371..379
app/helpers/vm_helper/textual_summary.rb on lines 382..390
app/helpers/vm_helper/textual_summary.rb on lines 417..425
app/helpers/vm_helper/textual_summary.rb on lines 428..436
app/helpers/vm_helper/textual_summary.rb on lines 449..457

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

  def textual_flavor
    flavor = @record.flavor
    h = {:label => _('Flavor'), :icon => "pficon-flavor", :value => (flavor.nil? ? _("None") : flavor.name)}
    if flavor && role_allows?(:feature => "flavor_show")
      h[:title] = _("Show this VM's Flavor")
Severity: Major
Found in app/helpers/vm_helper/textual_summary.rb and 6 other locations - About 45 mins to fix
app/helpers/cloud_volume_helper/textual_summary.rb on lines 70..81
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 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 4 locations. Consider refactoring.
Open

  def textual_usage_snapshots
    h = {:label => _("Snapshots")}
    value = @record.snapshot_storage
    h[:title] = value.nil? ? _("N/A") : "#{number_with_delimiter(value)} bytes"
    h[:value] = value.nil? ? _("N/A") : number_to_human_size(value, :precision => 2)
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.rb and 3 other locations - About 30 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 496..501
app/helpers/vm_helper/textual_summary.rb on lines 504..509
app/helpers/vm_helper/textual_summary.rb on lines 534..539

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

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_allocated_disks
    h = {:label => _("Disks")}
    value = @record.allocated_disk_storage
    h[:title] = value.nil? ? _("N/A") : "#{number_with_delimiter(value)} bytes"
    h[:value] = value.nil? ? _("N/A") : number_to_human_size(value, :precision => 2)
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.rb and 3 other locations - About 30 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 504..509
app/helpers/vm_helper/textual_summary.rb on lines 526..531
app/helpers/vm_helper/textual_summary.rb on lines 534..539

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

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_usage_disk_storage
    h = {:label => _("Total Datastore Used Space")}
    value = @record.used_disk_storage
    h[:title] = value.nil? ? _("N/A") : "#{number_with_delimiter(value)} bytes"
    h[:value] = value.nil? ? _("N/A") : number_to_human_size(value, :precision => 2)
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.rb and 3 other locations - About 30 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 496..501
app/helpers/vm_helper/textual_summary.rb on lines 504..509
app/helpers/vm_helper/textual_summary.rb on lines 526..531

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

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_allocated_memory
    h = {:label => _("Memory")}
    value = @record.ram_size_in_bytes_by_state
    h[:title] = value.nil? ? _("N/A") : "#{number_with_delimiter(value)} bytes"
    h[:value] = value.nil? ? _("N/A") : number_to_human_size(value, :precision => 2)
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.rb and 3 other locations - About 30 mins to fix
app/helpers/vm_helper/textual_summary.rb on lines 496..501
app/helpers/vm_helper/textual_summary.rb on lines 526..531
app/helpers/vm_helper/textual_summary.rb on lines 534..539

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

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

    if service.nil?
      h[:value] = _("None")
    else
      h[:value] = service.name
      h[:title] = _("Show this Service")
Severity: Minor
Found in app/helpers/vm_helper/textual_summary.rb and 1 other location - About 15 mins to fix
app/helpers/orchestration_stack_helper/textual_summary.rb on lines 53..58

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

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