theodi/odi-metrics-tasks

View on GitHub

Showing 14 of 18 total issues

Method reach has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def self.reach(year = nil, month = nil)
    total_block = Proc.new { |x| x.class == Hash ? x[:actual] : x }
    if year.nil? && month.nil?
      # Total comes from a single cell
      total = metrics_cell 'People reached', "lifetime", method(:integize)
Severity: Minor
Found in lib/google_drive/network_metrics.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 total_costs has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.total_costs(year, month)
    if year < 2015
      block = Proc.new { |x| floatize(x) }
      breakdown = {
        variable: extract_metrics(
Severity: Minor
Found in lib/google_drive/financial_metrics.rb - About 1 hr to fix

    Method reach has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.reach(year = nil, month = nil)
        total_block = Proc.new { |x| x.class == Hash ? x[:actual] : x }
        if year.nil? && month.nil?
          # Total comes from a single cell
          total = metrics_cell 'People reached', "lifetime", method(:integize)
    Severity: Minor
    Found in lib/google_drive/network_metrics.rb - About 1 hr to fix

      Method metric_with_target has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def metric_with_target name, year, month, block
          location             = cell_location(year, name)
          return nil if location.nil? # check we have a valid ref
          location['document'] ||= @@lookups['document_keys'][environment]['default']
          ytd_method = location['ytd_method'] || @@lookups['default_ytd_method']
      Severity: Minor
      Found in lib/helpers/google_drive_helper.rb - About 1 hr to fix

        Method gender has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.gender
            gender_sheet = metrics_worksheet("diversity", "Gender")
            genders = {}
            (3..99).each do |row|
              gender = gender_sheet["C#{row}"]
        Severity: Minor
        Found in lib/diversity/diversity_metrics.rb - About 1 hr to fix

          Method board_ids has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def board_ids
              {
                  2013 => {
                      :q1 => 'cEwY2JHh',
                      :q2 => 'm5Gxybf6',
          Severity: Minor
          Found in lib/trello/trello_boards.rb - About 1 hr to fix

            Method income has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.income(year, month)
                slice_by = month ? month : 12
                block = Proc.new { |x| x.is_a?(Array) ? x.slice(0, slice_by).inject(0.0) { |s,v| s += floatize(v) } : floatize(x) }
                if year.nil? && month.nil?
                  years.inject(0) do |memo, year|
            Severity: Minor
            Found in lib/google_drive/financial_metrics.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 people_trained has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.people_trained(year = nil, month = nil)
                if year.nil? && month.nil?
                  metrics_cell('People trained', "lifetime", method(:integize))
                else
                  h     = {
            Severity: Minor
            Found in lib/google_drive/network_metrics.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 metric_with_target has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def metric_with_target name, year, month, block
                location             = cell_location(year, name)
                return nil if location.nil? # check we have a valid ref
                location['document'] ||= @@lookups['document_keys'][environment]['default']
                ytd_method = location['ytd_method'] || @@lookups['default_ytd_method']
            Severity: Minor
            Found in lib/helpers/google_drive_helper.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 metrics_cell has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def metrics_cell identifier, year, block, ref = "cell_ref"
                location             = cell_location(year, identifier)
                return nil if location.nil? # check we have a valid ref
                location['document'] ||= @@lookups['document_keys'][environment]['default']
                multiplier = location['multiplier'] || @@lookups['default_multiplier']
            Severity: Minor
            Found in lib/helpers/google_drive_helper.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 bookings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.bookings(year, month)
                slice_by = month ? month : 12
                block = Proc.new { |x| x.is_a?(Array) ? x.slice(0, slice_by).inject(0) { |s,v| s += integize(v) } : integize(x) }
                if year.nil? && month.nil?
                  metrics_cell 'Total bookings', "lifetime", block
            Severity: Minor
            Found in lib/google_drive/financial_metrics.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 gender has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.gender
                gender_sheet = metrics_worksheet("diversity", "Gender")
                genders = {}
                (3..99).each do |row|
                  gender = gender_sheet["C#{row}"]
            Severity: Minor
            Found in lib/diversity/diversity_metrics.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 total_costs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.total_costs(year, month)
                if year < 2015
                  block = Proc.new { |x| floatize(x) }
                  breakdown = {
                    variable: extract_metrics(
            Severity: Minor
            Found in lib/google_drive/financial_metrics.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

            Method perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.perform
            
                data = {}
            
                coverage_sectors.each do |sector|
            Severity: Minor
            Found in lib/capsulecrm/membership_coverage.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