bf4/metric_fu

View on GitHub

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

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

            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

            Severity
            Category
            Status
            Source
            Language