seattlerb/flog

View on GitHub
lib/flog.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Flog has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

class Flog < MethodBasedSexpProcessor
  VERSION = "4.8.0" # :nodoc:

  ##
  # Cut off point where the report should stop unless --all given.
Severity: Minor
Found in lib/flog.rb - About 4 hrs to fix

    File flog.rb has 361 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "sexp_processor"
    require "ruby_parser"
    require "timeout"
    
    ##
    Severity: Minor
    Found in lib/flog.rb - About 4 hrs to fix

      Method flog_ruby has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def flog_ruby ruby, file="-", timeout = 10
          flog_ruby! ruby, file, timeout
        rescue Timeout::Error
          warn "TIMEOUT parsing #{file}. Skipping."
        rescue RubyParser::SyntaxError, Racc::ParseError => e
      Severity: Minor
      Found in lib/flog.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 flog has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def flog(*files)
          files.each do |file|
            next unless file == "-" or File.readable? file
      
            ruby = file == "-" ? $stdin.read : File.binread(file)
      Severity: Minor
      Found in lib/flog.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 process_iter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def process_iter(exp)
          context = (self.context - [:class, :module, :scope])
          context = context.uniq.sort_by { |s| s.to_s }
      
          exp.delete 0 # { || ... } has 0 in arg slot
      Severity: Minor
      Found in lib/flog.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

      There are no issues that match your filters.

      Category
      Status