Showing 12 of 26 total issues
Method viewDidAppear
has 150 lines of code (exceeds 25 allowed). Consider refactoring. Open
def viewDidAppear(animated)
if Medic.available?
types = {
share: [
Method predicate
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def predicate(args={})
return args if args.is_a? NSPredicate
if args[:where]
args[:where]
elsif args[:predicate]
- 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 samples_to_hashes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def samples_to_hashes(samples)
samples.map do |sample|
h = {}
h[:uuid] = sample.UUID.UUIDString
h[:metadata] = sample.metadata
- 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 anchor_for_symbol
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def anchor_for_symbol(sym)
return unless sym
return sym if sym.to_s == '0'
return sym if sym.is_a? Fixnum
return sym if sym.is_a? NSDate
- 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 predicate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def predicate(args={})
return args if args.is_a? NSPredicate
if args[:where]
args[:where]
elsif args[:predicate]
Method samples_to_hashes
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def samples_to_hashes(samples)
samples.map do |sample|
h = {}
h[:uuid] = sample.UUID.UUIDString
h[:metadata] = sample.metadata
Method statistics_to_hash
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def statistics_to_hash(stats)
h = {}
h[:start_date] = stats.startDate
h[:end_date] = stats.endDate
h[:sources] = stats.sources.map(&:name) if stats.sources
- 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_steps
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_steps
query = Medic::StatisticsCollectionQuery.new(type: :step_count, options: :sum, anchor: one_day_ago, interval: :day)
query.initial_results_handler = ->(query, results, error){
NSLog("An error occurred calculating statistics: #{error.localizedDescription}") if error
- 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 prepare_for_save
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def prepare_for_save(sample)
return sample if sample.kind_of? HKSample
date = sample[:date] || NSDate.date
start_date = sample[:start] || sample[:start_date] || date
- 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 viewDidAppear
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def viewDidAppear(animated)
query_params = { type: :step_count, options: :sum, anchor: one_week_ago, interval: :day }
query = Medic::StatisticsCollectionQuery.new(query_params) do |query, results, error|
NSLog("An error occurred calculating statistics: #{error.localizedDescription}") if error
- 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 interval
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def interval(sym)
return sym if sym.is_a? NSDateComponents
parts = sym.to_s.gsub('_', ' ').split
component = parts.pop.chomp('s')
n = parts.map{|p| NUMBER_WORDS[p] || p.to_i}.reduce do |sum, p|
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(args={})
@params = args
@query = HKStatisticsCollectionQuery.alloc.initWithQuantityType(object_type(args[:type]),
quantitySamplePredicate: predicate(args),
options: options_for_stat_query(args[:options]),
- 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"