Showing 225 of 225 total issues
Similar blocks of code found in 4 locations. Consider refactoring. Open
if @client.api_version.to_i > 200 && @client.api_version.to_i < 600
scope_1 = scope_class.new(@client, name: 'Scope 1')
scope_1.create!
scope_2 = scope_class.new(@client, name: 'Scope 2')
scope_2.create!
- Read upRead up
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 74.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module OneviewSDK
module API1200
module Synergy
# Ethernet network resource implementation for API1200 Synergy
class EthernetNetwork < OneviewSDK::API1000::Synergy::EthernetNetwork
- Read upRead up
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 71.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module OneviewSDK
module API1200
module C7000
# Ethernet network resource implementation for API1200 C7000
class EthernetNetwork < OneviewSDK::API1000::C7000::EthernetNetwork
- Read upRead up
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 71.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method wait_for
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def wait_for(task_uri)
raise ArgumentError, 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty?
loop do
task_uri.gsub!(%r{https:(.*)\/rest}, '/rest')
task = rest_get(task_uri)
- Read upRead up
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
module OneviewSDK
module API500
module C7000
# Enclosure resource implementation for API500 C7000
class Enclosure < OneviewSDK::API300::C7000::Enclosure
- Read upRead up
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 69.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module OneviewSDK
module API500
module Synergy
# Enclosure resource implementation for API500 Synergy
class Enclosure < OneviewSDK::API300::Synergy::Enclosure
- Read upRead up
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 69.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method generate_logical_switch_credentials
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_logical_switch_credentials
credentials = []
@logical_switch_credentials.each_value do |switch|
switch_credentials = []
switch_credentials << {
Method add_interconnect
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def add_interconnect(bay, type, logical_downlink = nil, enclosure_index = nil)
enclosure_index ||= type.include?('Virtual Connect SE 16Gb FC Module') ? -1 : 1
entry = parse_interconnect_map_template(bay, enclosure_index)
entry['logicalDownlinkUri'] ||= nil # Default value in case of no specified logical downlink
if logical_downlink
- Read upRead up
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 add_lig_to_bay
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def add_lig_to_bay(bay, lig, enclosureIndex)
@data['interconnectBayMappings'].each do |location|
next unless location['interconnectBay'] == bay
if enclosureIndex
next unless location['enclosureIndex'] == enclosureIndex
- Read upRead up
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 build_request
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def build_request(type, uri, options, api_ver)
case type.downcase.to_sym
when :get
request = Net::HTTP::Get.new(uri.request_uri)
when :post
- Read upRead up
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 like?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def like?(other)
if other.is_a? Hash
other_copy = Marshal.load(Marshal.dump(other))
else
other_copy = other.dup
- Read upRead up
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 from_file
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.from_file(client, file_path)
resource = OneviewSDK::Config.load(file_path)
klass = self
if klass == OneviewSDK::Resource && resource['type'] # Use correct resource class by parsing type
klass = OneviewSDK # Secondary/temp class/module reference
- Read upRead up
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 retrieve!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def retrieve!
ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] rescue nil
if ip_hostname
results = self.class.find_by(@client, credentials: { ip_hostname: ip_hostname })
if results.size == 1
- Read upRead up
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 retrieve!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def retrieve!
hostname = @data['hostname'] || @data['mpHostInfo']['mpHostName'] rescue nil
if hostname
results = self.class.find_by(@client, 'mpHostInfo' => { 'mpHostName' => hostname })
if results.size == 1
- Read upRead up
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_volume_with_attachment
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create_volume_with_attachment(storage_pool, volume_options, attachment_options = {})
raise IncompleteResource, 'Storage Pool not found!' unless storage_pool.retrieve!
# Convert symbols keys to string in volume_options and attachment_options
volume_options = Hash[volume_options.map { |k, v| [k.to_s, v] }]
attachment_options = Hash[attachment_options.map { |k, v| [k.to_s, v] }]
- Read upRead up
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 upload_file
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload_file(file_path, path, options = {}, timeout = READ_TIMEOUT)
raise NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path)
options = Hash[options.map { |k, v| [k.to_s, v] }]
body_params = options['body'] || {}
headers_params = options['header'] || {}
Method initialize
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(options = {})
options = Hash[options.map { |k, v| [k.to_sym, v] }] # Convert string hash keys to symbols
STDOUT.sync = true
@logger = options[:logger] || Logger.new(STDOUT)
%i[debug info warn error level=].each { |m| raise InvalidClient, "Logger must respond to #{m} method " unless @logger.respond_to?(m) }
Method create_from_file
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_from_file(file_path)
client_setup
resource = OneviewSDK::Resource.from_file(@client, file_path)
fail_nice 'Failed to determine resource type!' if resource.class == OneviewSDK::Resource
existing_resource = resource.class.new(@client, resource.data)
Method response_handler
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def response_handler(response, wait_on_task = true)
case response.code.to_i
when RESPONSE_CODE_OK # Synchronous read/query
begin
return JSON.parse(response.body)
- Read upRead up
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 retrieve!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def retrieve!
raise IncompleteResource, 'Must set resource name or uri before trying to retrieve!' unless @data['name'] || @data['uri']
raise IncompleteResource, 'Must set resource storageSystemUri before trying to retrieve!' unless @data['storageSystemUri']
results = self.class.find_by(@client, name: @data['name'], storageSystemUri: @data['storageSystemUri']) if @data['name']
results = self.class.find_by(@client, uri: @data['uri'], storageSystemUri: @data['storageSystemUri']) if @data['uri'] &&
- Read upRead up
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"