File twitter.rb
has 401 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'json'
require_relative '../util/csv_file_dumper'
require_relative '../../../../twitter-search/twitter-search'
Class Twitter
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Twitter < BaseFileStream
include ::LoggerHelper
# Required for all datasources
Method search_by_category
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def search_by_category(api, base_filters, category)
api.params = base_filters
exception = nil
next_results_cursor = 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 search_by_category
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search_by_category(api, base_filters, category)
api.params = base_filters
exception = nil
next_results_cursor = nil
Method build_queries_from_fields
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def build_queries_from_fields(fields)
raise ParameterError.new('missing categories', DATASOURCE_NAME) \
if fields[:categories].nil? || fields[:categories].empty?
queries = []
- 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_date_from_fields
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def build_date_from_fields(fields, date_type)
raise ParameterError.new('missing dates', DATASOURCE_NAME) \
if fields[:dates].nil?
case date_type
- 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 do_search
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_search(api_config, redis_storage, filters, stream)
threads = {}
base_filters = filters.select { |k, v| k != FILTER_CATEGORIES }
category_totals = {}
Method build_date_from_fields
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_date_from_fields(fields, date_type)
raise ParameterError.new('missing dates', DATASOURCE_NAME) \
if fields[:dates].nil?
case date_type
Method initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(config, user, redis_storage = nil, user_defined_limits={})
@service_name = DATASOURCE_NAME
@filters = Hash.new
raise UninitializedError.new('missing user instance', DATASOURCE_NAME) if user.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 build_maxresults_field
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_maxresults_field(user)
if twitter_credit_limits > 0
[remaining_quota, TwitterSearch::SearchAPI::MAX_PAGE_RESULTS].min
else
# user about to hit quota?
- 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"