Showing 28 of 28 total issues
Method schema_contains?
has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring. Open
def schema_contains?(options)
publish = options[:publish]
consume = options[:consume]
location = options[:location] || []
return false unless publish and consume
- 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 schema_contains?
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
def schema_contains?(options)
publish = options[:publish]
consume = options[:consume]
location = options[:location] || []
return false unless publish and consume
Method install_tasks
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def install_tasks
namespace :lacerda do
desc "Clean up intermediary json files"
task :cleanup do
path = File.expand_path("../contracts")
- 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 contracts_fulfilled?
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def contracts_fulfilled?(reporter = nil)
reporter = Lacerda.validate_reporter(reporter)
@mutex1.synchronize do
@errors = {}
- 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 install_tasks
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install_tasks
namespace :lacerda do
desc "Clean up intermediary json files"
task :cleanup do
path = File.expand_path("../contracts")
Method contracts_fulfilled?
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def contracts_fulfilled?(reporter = nil)
reporter = Lacerda.validate_reporter(reporter)
@mutex1.synchronize do
@errors = {}
Method mson_to_json_schema!
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.mson_to_json_schema!(options)
filename = options.fetch(:filename)
# For now, we'll use the containing directory's name as a scope
service_scope = File.dirname(filename).split(File::SEPARATOR).last.underscore
Avoid deeply nested control flow statements. Open
unless compatible_consume_type_found
return _e(:ERR_MISSING_SINGLE_PUBLISH_MULTI_CONSUME, location, publish['type'])
end
Avoid deeply nested control flow statements. Open
if publish_types.size == 1 && consume_types.size == 1
@errors.push(*errors)
else
_e(:ERR_MISSING_MULTI_PUBLISH_MULTI_CONSUME, location, publish_type)
end
Avoid deeply nested control flow statements. Open
next unless schema_contains?(publish: publish, consume: consume_type, location: location)
Avoid deeply nested control flow statements. Open
elsif consume['properties'] and publish['oneOf']
publish_types = ([publish['oneOf']].flatten - [{"type" => "null"}]).sort
incompatible_publish_type= nil
original_errors = @errors
@errors = []
Consider simplifying this complex logical expression. Open
return _e(:ERR_MISSING_TYPE_AND_REF_AND_ONE_OF, location) unless
(consume['type'] or consume['$ref'] or consume['oneOf']) and
(publish['type'] or publish['$ref'] or publish['oneOf'])
Avoid too many return
statements within this method. Open
return _e(:ERR_MISSING_REQUIRED, location, missing.to_json) unless missing.empty?
Avoid too many return
statements within this method. Open
return _e(:ERR_MISSING_PROPERTY, location, property) unless publish['properties'][property]
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return _e(:ERR_NOT_IMPLEMENTED, location, "'items' can only be hash (schema)")
Avoid too many return
statements within this method. Open
return _e(:ERR_ARRAY_ITEM_MISMATCH, location, nil)
Avoid too many return
statements within this method. Open
return _e(:ERR_NOT_SUPPORTED, location, nil)
Avoid too many return
statements within this method. Open
return _e(:ERR_MISSING_MULTI_PUBLISH_SINGLE_CONSUME, location, incompatible_publish_type)
Avoid too many return
statements within this method. Open
return _e(:ERR_NOT_SUPPORTED, location, "Consume schema didn't have properties defined and publish schema no oneOf")