app/models/position_opening.rb
Method search_for
has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring. Open
Open
def search_for(options = {})
options.reverse_merge!(size: 10, from: 0)
document_limit = [options[:size].to_i, MAX_RETURNED_DOCUMENTS].min
source = options[:source]
sort_by = options[:sort_by] || :timestamp
- 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 search_for
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def search_for(options = {})
options.reverse_merge!(size: 10, from: 0)
document_limit = [options[:size].to_i, MAX_RETURNED_DOCUMENTS].min
source = options[:source]
sort_by = options[:sort_by] || :timestamp
File position_opening.rb
has 346 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'active_model'
require 'elasticsearch/dsl'
class PositionOpening
include ActiveModel::Model
Method delete_expired_docs
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def delete_expired_docs
query = Elasticsearch::DSL::Search.search do
query do
bool do
filter do
Method import
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def import(position_openings)
position_openings.each do |opening|
data = opening.each_with_object(timestamp: DateTime.current) do |(key, value), d|
d[key] =
case key