bf4/metric_fu

View on GitHub

Showing 48 of 48 total issues

Class Configuration has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Configuration

    def initialize #:nodoc:#
      reset
    end
Severity: Minor
Found in lib/metric_fu/configuration.rb - About 3 hrs to fix

    Class Template has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Template
        attr_accessor :report, :per_file_data
    
        private
        # Creates a new erb evaluated result from the passed in section.
    Severity: Minor
    Found in lib/metric_fu/metrics/base_template.rb - About 2 hrs to fix

      Method add_method_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_method_data
            @rcov.each_pair do |file_path, info|
              file_contents = ""
              coverage = []
      
      
      Severity: Minor
      Found in lib/metric_fu/metrics/rcov/rcov.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 get_elements has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_elements
            begin
              while (line = @file_handle.readline) do
                return [] if line.nil? || line !~ /\S/
                element ||= nil
      Severity: Minor
      Found in lib/metric_fu/metrics/saikuro/saikuro.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 per_file_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def per_file_info(out)
            @saikuro_data[:files].each do |file_data|
              next if File.extname(file_data[:filename]) == '.erb' || !File.exists?(file_data[:filename])
              begin
                line_numbers = MetricFu::LineNumbers.new(File.open(file_data[:filename], 'r').read)
      Severity: Minor
      Found in lib/metric_fu/metrics/saikuro/saikuro.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 per_file_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def per_file_info(out)
            @matches.each do |file_data|
              file_path = file_data[:file_path]
              next if File.extname(file_path) =~ /\.erb|\.html|\.haml/
              begin
      Severity: Minor
      Found in lib/metric_fu/metrics/reek/reek.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 write_file_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def write_file_data
      
          per_file_data.each_pair do |file, lines|
            data = File.open(file, 'r').readlines
            fn = "#{file.gsub(%r{/}, '_')}.html"
      Severity: Minor
      Found in lib/metric_fu/reporting/templates/awesome/awesome_template.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 write_file_data has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def write_file_data
      
          per_file_data.each_pair do |file, lines|
            data = File.open(file, 'r').readlines
            fn = "#{file.gsub(%r{/}, '_')}.html"
      Severity: Minor
      Found in lib/metric_fu/reporting/templates/awesome/awesome_template.rb - About 1 hr to fix

        Method get_metrics has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_metrics(metrics, date)
              if metrics && metrics[:reek]
                counter = @labels.size
                @labels.update( { @labels.size => date })
        
        
        Severity: Minor
        Found in lib/metric_fu/metrics/reek/reek_grapher.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 add_method_data has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def add_method_data
              @rcov.each_pair do |file_path, info|
                file_contents = ""
                coverage = []
        
        
        Severity: Minor
        Found in lib/metric_fu/metrics/rcov/rcov.rb - About 1 hr to fix

          Method write has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def write
              # Getting rid of the crap before and after the project name from integrity
              # @name = File.basename(Dir.pwd).gsub(/^\w+-|-\w+$/, "")
              @name = Pathname.new(Dir.pwd).basename
          
          
          Severity: Minor
          Found in lib/metric_fu/reporting/templates/awesome/awesome_template.rb - About 1 hr to fix

            Method validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def validate(options) # remove this method if you want fewer lines of code and don't need validations
                      options.each_pair do |key, value|
                        opt = @options.find_all{ |o| o[0] == key }.first
                        key = "--" << key.to_s.gsub("_", "-")
                        unless opt[2][:value_in_set].nil? || opt[2][:value_in_set].include?(value)
            Severity: Minor
            Found in lib/metric_fu/cli/parser.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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.get(file_path, class_name, method_name)
                  # This could be more 'confident' using Maybe, but we want it to be as fast as possible
                  file_path_copy = file_path == nil ? nil : file_path.clone
                  class_name_copy = class_name == nil ? nil : class_name.clone
                  method_name_copy = method_name == nil ? nil : method_name.clone
            Severity: Minor
            Found in lib/metric_fu/data_structures/location.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 file_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def file_url(name, line) # :nodoc:
                  return '' unless name
                  filename = complete_file_path(name)
                  link_prefix = MetricFu.configuration.link_prefix
                  if link_prefix
            Severity: Minor
            Found in lib/metric_fu/metrics/base_template.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

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

            module MetricFu
              class StatsBluffGrapher < StatsGrapher
                def graph!
                  content = <<-EOS
                    #{BLUFF_DEFAULT_OPTIONS}
            Severity: Minor
            Found in lib/metric_fu/metrics/stats/stats_bluff_grapher.rb and 1 other location - About 40 mins to fix
            lib/metric_fu/metrics/flog/flog_bluff_grapher.rb on lines 2..13

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

            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

            module MetricFu
              class FlogBluffGrapher < FlogGrapher
                def graph!
                  content = <<-EOS
                    #{BLUFF_DEFAULT_OPTIONS}
            Severity: Minor
            Found in lib/metric_fu/metrics/flog/flog_bluff_grapher.rb and 1 other location - About 40 mins to fix
            lib/metric_fu/metrics/stats/stats_bluff_grapher.rb on lines 2..13

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

            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

            module MetricFu
              class RoodiGchartGrapher < RoodiGrapher
                def graph!
                  determine_y_axis_scale(@roodi_count)
                  url = Gchart.line(
            Severity: Minor
            Found in lib/metric_fu/metrics/roodi/roodi_gchart_grapher.rb and 1 other location - About 35 mins to fix
            lib/metric_fu/metrics/flay/flay_gchart_grapher.rb on lines 2..14

            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

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

            module MetricFu
              class FlayGrapher < Grapher
                attr_accessor :flay_score, :labels
            
                def initialize
            Severity: Minor
            Found in lib/metric_fu/metrics/flay/flay_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/roodi/roodi_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

            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

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

            module MetricFu
              class CaneGrapher < Grapher
                attr_accessor :cane_violations, :labels
            
                def initialize
            Severity: Minor
            Found in lib/metric_fu/metrics/cane/cane_grapher.rb and 2 other locations - About 35 mins to fix
            lib/metric_fu/metrics/flay/flay_grapher.rb on lines 2..16
            lib/metric_fu/metrics/roodi/roodi_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

            Severity
            Category
            Status
            Source
            Language