HewlettPackard/oneview-puppet

View on GitHub
lib/puppet/provider/oneview_server_hardware/c7000.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method data_parse_for_general has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def data_parse_for_general
    %w(from op path value).each { |key| @patch_tags[key] = @data.delete(key) if @data[key] }
    @data['name'] = @data.delete('hostname') if @data['hostname']
    @data.each_key do |key|
      case key
Severity: Minor
Found in lib/puppet/provider/oneview_server_hardware/c7000.rb - About 45 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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    return patch unless @patch_tags.empty?
    return true if resource_update
    @data = @data.merge(@authentication)
    @data['hostname'] = @data.delete('name') if @data['name']
Severity: Minor
Found in lib/puppet/provider/oneview_server_hardware/c7000.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 set_power_state_validation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def set_power_state_validation
    raise 'A "power_state" specified in data is required for this action.' unless @data['power_state']
    power_state = @data.delete('power_state')
    raise 'Invalid power_state specified in data. Valid values are "On" or "Off"' unless
      power_state.casecmp('off').zero? || power_state.casecmp('on').zero?
Severity: Minor
Found in lib/puppet/provider/oneview_server_hardware/c7000.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 patch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def patch
    raise 'The "from" tag is not supported by the current version of the ruby sdk' if @patch_tags['from']
    raise 'The "op", "path" and "value" tags are required together when used for this operation.' unless
      @patch_tags['op'] && @patch_tags['path'] && @patch_tags['value']
    server_hardware = get_single_resource_instance
Severity: Minor
Found in lib/puppet/provider/oneview_server_hardware/c7000.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

There are no issues that match your filters.

Category
Status