ryanlntn/medic

View on GitHub

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: [
Severity: Major
Found in app/controllers/authorize_controller.rb - About 6 hrs to fix

    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]
    Severity: Minor
    Found in lib/medic/predicate.rb - About 2 hrs to fix

    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
    Severity: Minor
    Found in lib/medic/finders.rb - About 2 hrs to fix

    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
    Severity: Minor
    Found in lib/medic/anchor.rb - About 1 hr to fix

    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]
    Severity: Minor
    Found in lib/medic/predicate.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in lib/medic/finders.rb - About 1 hr to fix

        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
        Severity: Minor
        Found in lib/medic/finders.rb - About 55 mins to fix

        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
        Severity: Minor
        Found in app/controllers/observer_query_controller.rb - About 45 mins to fix

        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
        Severity: Minor
        Found in lib/medic/store.rb - About 45 mins to fix

        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
        Severity: Minor
        Found in app/controllers/statistics_collection_query_controller.rb - About 45 mins to fix

        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|
        Severity: Minor
        Found in lib/medic/interval.rb - About 35 mins to fix

        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]),
        Severity: Minor
        Found in lib/medic/statistics_collection_query_builder.rb - About 25 mins to fix

        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

        Severity
        Category
        Status
        Source
        Language