theodi/odi-metrics-tasks

View on GitHub

Showing 18 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              def self.perform
                # Connect
                github = Github.connection
                # Count up stats across all repositories
                open_issues = github.search.issues(q: "is:open is:issue user:#{ENV['GITHUB_ORGANISATION']}").total_count
            Severity: Minor
            Found in lib/github/issue_monitor.rb and 1 other location - About 50 mins to fix
            lib/github/pull_request_monitor.rb on lines 10..21

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 43.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              def self.perform
                # Connect
                github = Github.connection
                open_pull_requests = github.search.issues(q: "is:open is:pr user:#{ENV['GITHUB_ORGANISATION']}").total_count
                # Push into metrics
            Severity: Minor
            Found in lib/github/pull_request_monitor.rb and 1 other location - About 50 mins to fix
            lib/github/issue_monitor.rb on lines 7..19

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 43.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              def self.grant_funding(year, month)
                block = Proc.new { |x| x.is_a?(Array) ? x.slice(0, month).inject(0.0) { |s,v| s += floatize(v) } : floatize(x) }
                metric_with_target 'Grant Funding', year, month, block
            Severity: Minor
            Found in lib/google_drive/financial_metrics.rb and 1 other location - About 30 mins to fix
            lib/google_drive/financial_metrics.rb on lines 113..123

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 32.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              def self.ebitda(year, month)
                block = Proc.new do |x|
                  if x.is_a?(Array)
                    x.slice(0,month).inject(0.0) do |s,v|
                      s += floatize(v)
            Severity: Minor
            Found in lib/google_drive/financial_metrics.rb and 1 other location - About 30 mins to fix
            lib/google_drive/financial_metrics.rb on lines 66..68

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 32.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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