Showing 12 of 12 total issues
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.
File flog.rb
has 361 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "sexp_processor"
require "ruby_parser"
require "timeout"
##
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
- Read upRead up
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 parse_options
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse_options args = ARGV, extra_options = {}
option = {
:quiet => false,
:continue => false,
:parser => RubyParser,
Method display_report
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def display_report max = 10
scores = @data.reject { |k,v| v[:total].nil? or v[:methods].empty? }
project_numbers = scores.map { |k,v| [k, v[:methods].values] }
project_stats = project_numbers.map { |k,v| [k, scores[k][:size], v.average, v.stddev] }
Method display_report
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def display_report max = 10
scores = @data.reject { |k,v| v[:total].nil? or v[:methods].empty? }
project_numbers = scores.map { |k,v| [k, v[:methods].values] }
project_stats = project_numbers.map { |k,v| [k, scores[k][:size], v.average, v.stddev] }
- Read upRead up
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 load_plugins
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.load_plugins
# TODO: I think I want to do this more like hoe's plugin system. Generalize?
loaded, found = {}, {}
Gem.find_files("flog/*.rb").reverse.each do |path|
- Read upRead up
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 group_by_owner
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def group_by_owner
latest_gems.each do |spec|
name = spec.name
owner = spec.authors.compact
owner = Array(spec.email) if owner.empty?
- Read upRead up
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)
- Read upRead up
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
- Read upRead up
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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize name = :flog, threshold = 200, dirs = nil, method = nil, methods_only = false
Method define
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def define
desc "Analyze for code complexity in: #{dirs.join(', ')}"
task name do
require "flog_cli"
flog = FlogCLI.new :continue => true, :quiet => true, :methods => @methods_only
- Read upRead up
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"