bf4/metric_fu

View on GitHub

Showing 48 of 48 total issues

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

module MetricFu
  class RoodiGrapher < Grapher
    attr_accessor :roodi_count, :labels

    def initialize
Severity: Minor
Found in lib/metric_fu/metrics/roodi/roodi_grapher.rb and 2 other locations - About 35 mins to fix
lib/metric_fu/metrics/cane/cane_grapher.rb on lines 2..16
lib/metric_fu/metrics/flay/flay_grapher.rb on lines 2..16

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 36.

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 pluralize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def pluralize(word)
      result = word.to_s.dup

      if word.empty? || inflections.uncountables.include?(result.downcase)
        result
Severity: Minor
Found in lib/metric_fu/core_ext/inflector/inflections.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 for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.for(class_or_method_name)
      class_or_method_name = strip_modules(class_or_method_name)
      if(class_or_method_name)
        begin
          match = class_or_method_name.match(/(.*)((\.|\#|\:\:[a-z])(.+))/)
Severity: Minor
Found in lib/metric_fu/data_structures/location.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 7 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(contents,file_path='')
      if contents.to_s.size.zero?
        puts "NON PARSEABLE INPUT: File is empty at path #{file_path.inspect}\n\t#{caller.join("\n\t")}"
      else
        rp = RubyParser.new
Severity: Minor
Found in lib/metric_fu/data_structures/line_numbers.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 constantize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def constantize(camel_cased_word) #:nodoc:
        names = camel_cased_word.split('::')
        names.shift if names.empty? || names.first.empty?

        constant = Object
Severity: Minor
Found in lib/metric_fu/core_ext/inflector/methods.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 constantize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def constantize(camel_cased_word)
        names = camel_cased_word.split('::')
        names.shift if names.empty? || names.first.empty?

        constant = Object
Severity: Minor
Found in lib/metric_fu/core_ext/inflector/methods.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 emit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def emit
      files = []
      MetricFu.flog[:dirs_to_flog].each do |directory|
        directory = "." if directory=='./'
        dir_files = Dir.glob("#{directory}/**/*.rb")
Severity: Minor
Found in lib/metric_fu/metrics/flog/flog.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 configure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.configure
    MetricFu.lib_require { 'core_ext' }
    MetricFu.lib_require { 'configuration' }
    init_files = Dir.glob(File.join(MetricFu.metrics_dir, '**/init.rb')).reject do |file|
      if file =~ /rcov/o
Severity: Minor
Found in lib/metric_fu.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 emit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def emit
      options_string = MetricFu.saikuro.inject("") do |options, option|
        option[0] == :input_directory ? options : options + "--#{option.join(' ')} "
      end

Severity: Minor
Found in lib/metric_fu/metrics/saikuro/saikuro.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 5 locations. Consider refactoring.
Open

module MetricFu
  class RailsBestPracticesBluffGrapher < RailsBestPracticesGrapher
    def graph!
      content = <<-EOS
        #{BLUFF_DEFAULT_OPTIONS}
lib/metric_fu/metrics/cane/cane_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/flay/flay_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb on lines 2..12

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 5 locations. Consider refactoring.
Open

module MetricFu
  class FlayBluffGrapher < FlayGrapher
    def graph!
      content = <<-EOS
        #{BLUFF_DEFAULT_OPTIONS}
Severity: Major
Found in lib/metric_fu/metrics/flay/flay_bluff_grapher.rb and 4 other locations - About 30 mins to fix
lib/metric_fu/metrics/cane/cane_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb on lines 2..12

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 5 locations. Consider refactoring.
Open

module MetricFu
  class RcovBluffGrapher < RcovGrapher
    def graph!
      content = <<-EOS
        #{BLUFF_DEFAULT_OPTIONS}
Severity: Major
Found in lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb and 4 other locations - About 30 mins to fix
lib/metric_fu/metrics/cane/cane_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/flay/flay_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb on lines 2..12

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 5 locations. Consider refactoring.
Open

module MetricFu
  class CaneBluffGrapher < CaneGrapher
    def graph!
      content = <<-EOS
        #{BLUFF_DEFAULT_OPTIONS}
Severity: Major
Found in lib/metric_fu/metrics/cane/cane_bluff_grapher.rb and 4 other locations - About 30 mins to fix
lib/metric_fu/metrics/flay/flay_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb on lines 2..12

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 5 locations. Consider refactoring.
Open

module MetricFu
  class RoodiBluffGrapher < RoodiGrapher
    def graph!
      content = <<-EOS
        #{BLUFF_DEFAULT_OPTIONS}
Severity: Major
Found in lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb and 4 other locations - About 30 mins to fix
lib/metric_fu/metrics/cane/cane_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/flay/flay_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb on lines 2..12
lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb on lines 2..12

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 per_file_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def per_file_info(out)
      @rails_best_practices_results[:problems].each do |problem|
        next if problem[:file] == '' || problem[:problem].nil?

        out[problem[:file]] ||= {}
Severity: Minor
Found in lib/metric_fu/metrics/rails_best_practices/rails_best_practices.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 singularize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def singularize(word)
      result = word.to_s.dup

      if inflections.uncountables.any? { |inflection| result =~ /\b(#{inflection})\Z/i }
        result
Severity: Minor
Found in lib/metric_fu/core_ext/inflector/inflections.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 per_file_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def per_file_info(out)
      @method_containers.each_pair do |klass, container|
        container.methods.each_pair do |method_name, data|
          next if data[:path].nil?

Severity: Minor
Found in lib/metric_fu/metrics/flog/flog.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 lib_require has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.lib_require(base='',&block)
    paths = []
    base_path = File.join(LIB_ROOT, base)
    Array((yield paths, base_path)).each do |path|
      file = File.join(base_path, *Array(path))
Severity: Minor
Found in lib/metric_fu.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 fix_row_file_path! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def fix_row_file_path!(row)
      # We know that Saikuro rows are broken
      # next unless row['metric'] == :saikuro
      key = [row['class_name'], row['method_name']]
      current_file_path = row['file_path'].to_s
Severity: Minor
Found in lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.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 massage_for_reek_12 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def massage_for_reek_12
      section_break = ''
      @output.split("\n").map do |line|
        case line
        when /^  /
Severity: Minor
Found in lib/metric_fu/metrics/reek/reek.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