Showing 33 of 33 total issues
File constants.rb
has 354 lines of code (exceeds 250 allowed). Consider refactoring. Open
module PlentyClient
class Constants
AVAILABLE_LANGS = %w(de en bg fr it es tr nl pl pt nn ro da se cz ru sk cn vn).freeze
PAYMENT_STATUS_IDS = [
Method build_endpoint
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_endpoint(api_endpoint_template, arguments = {})
# Duplicate constant to temporary endpoint string
api_endpoint_result = api_endpoint_template.dup
# Endpoint parameters hash that links symbols to regex
endpoint_parameters = {
Method parse_body
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parse_body(response)
return nil if response.body.strip == ""
content_type = response.env.response_headers['Content-Type']
case content_type
when %r{(?:application|text)/json}
- 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 find_by_language
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_by_language(item_id, variation_id, property_id, lang, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, supplier_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, price_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, image_id, lang, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, plenty_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, property_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, category_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, sku_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, property_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, warehouse_id, headers = {}, &block)
Method find
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find(item_id, variation_id, bundle_id, headers = {}, &block)
Method update
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def update(item_id, variation_id, property_id, lang, headers = {})
Method request
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def request(http_method, path, params = {})
raise ArgumentError, "http_method or path is missing" if http_method.nil? || path.nil?
unless %w[post put patch delete get].include?(http_method.to_s)
raise ArgumentError, "unsupported http_method: #{http_method}"
end
- 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 get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get(path, params = {})
page = 1
rval_array = []
if block_given?
loop do
- 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 extract_message
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def extract_message(response)
if response.key?('validation_errors') && response['validation_errors'] && !response['validation_errors']&.empty?
errors = response['validation_errors']
rval = errors.values if response['validation_errors'].is_a?(Hash)
rval = errors.flatten.values if response['validation_errors'].is_a?(Array)
- 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
Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency faraday
should appear before json
. Open
spec.add_runtime_dependency 'faraday', '>= 0.9'
- Read upRead up
- Exclude checks
Dependencies in the gemspec should be alphabetically sorted.
Example:
# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'
# good
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
# good
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'
# good
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'
Inconsistent indentation detected. Open
faraday.request :retry, max: PlentyClient::Config.attempt_count
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end