Showing 10 of 83 total issues
Method search_for
has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring. 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
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
require 'active_model'
require 'elasticsearch/dsl'
class PositionOpening
include ActiveModel::Model
Method process_job
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def process_job(job_xml)
end_date_str = job_xml.xpath(XPATHS[:end_date]).inner_text.squish
pubdate = DateTime.parse(job_xml.xpath(XPATHS[:pubdate]).inner_text.squish)
now = DateTime.current.freeze
- 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 process_job
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_job(job_xml)
end_date_str = job_xml.xpath(XPATHS[:end_date]).inner_text.squish
pubdate = DateTime.parse(job_xml.xpath(XPATHS[:pubdate]).inner_text.squish)
now = DateTime.current.freeze
Method parse
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse(query)
query.gsub!(/volunteer(ing)? ?/) do
self.rate_interval_code = 'WC'
nil
end
Method delete_expired_docs
has 34 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
Method process_location_and_state
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def process_location_and_state(city_str, state_str)
city = city_str =~ INVALID_LOCATION_REGEX ? nil : remove_trailing_state_zip(strip_prefix(city_str.squish)).rpartition(',')[2].to_s.squish
state_name = state_str.squish
state = State.member?(state_name) ? State.normalize(state_name) : nil
- 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 process_job
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_job(job_xml)
end_date = Date.parse(job_xml.xpath(XPATHS[:end_date]).inner_text)
start_date = Date.parse(job_xml.xpath(XPATHS[:start_date]).inner_text)
days_remaining = (end_date - Date.current).to_i
inactive = job_xml.xpath(XPATHS[:status_code]).inner_text != 'Active'
- 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"