# toy/image_optim

### Showing 19 of 19 total issues

#### Method `find_to_optimize_recursive` has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open

``````    def find_to_optimize_recursive(dir)
to_optimize = []
Find.find(dir) do |path|
if File.file?(path)
next if exclude_file?(dir, path)``````
Found in lib/image_optim/runner.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"

#### Method `find_to_optimize` has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open

``````    def find_to_optimize(paths)
to_optimize = []
paths.each do |path|
if File.file?(path)
if @image_optim.optimizable?(path)``````
Found in lib/image_optim/runner.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"

#### Method `optimize` has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open

``````      def optimize(src, dst)
if jpegrescan
args = %W[
#{src}
#{dst}``````
Found in lib/image_optim/worker/jpegtran.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"

#### Method `symlink_custom_bin!` has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open

``````    def symlink_custom_bin!(name)
env_name = "#{name}_bin".upcase
path = ENV[env_name]
return unless path

``````
Found in lib/image_optim/bin_resolver.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"

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

``````      def optimize(src, dst)
args = %W[
-k#{copy_chunks ? 1 : 0}
-s#{strategy}
-q``````
Found in lib/image_optim/worker/pngout.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"

#### Method `resolve!` has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open

``````    def resolve!(name)
name = name.to_sym

resolving(name) do
Found in lib/image_optim/bin_resolver.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"

#### Method `read_options` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open

``````      def read_options(path)
begin
full_path = File.expand_path(path)
rescue ArgumentError => e
warn "Can't expand path #{path}: #{e}"``````
Found in lib/image_optim/config.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"

#### Method `optimize` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open

``````      def optimize(src, dst)
args = %W[
--output=#{dst}
--no-names``````
Found in lib/image_optim/worker/gifsicle.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"

#### Method `optimize` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open

``````      def optimize(src, dst)
src.copy(dst)
args = %W[
-o #{level}
-quiet``````
Found in lib/image_optim/worker/optipng.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"

#### Method `check_fail!` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open

``````      def check_fail!
unless version
fail UnknownVersion, "could not get version of #{name} at #{path}"
end

``````
Found in lib/image_optim/bin_resolver/bin.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"

#### Method `help` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open

``````      def help
text = super

# reserve one column
columns = terminal_columns - 1``````
Found in lib/image_optim/runner/option_parser.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"

#### Method `initialize` has 5 arguments (exceeds 4 allowed). Consider refactoring. Open

``    def initialize(name, default, type_or_description, description = nil, &proc)``
Found in lib/image_optim/option_definition.rb - About 35 mins to fix

#### Method `option` has 5 arguments (exceeds 4 allowed). Consider refactoring. Open

``      def option(name, default, type, description = nil, &proc)``
Found in lib/image_optim/worker/class_methods.rb - About 35 mins to fix

#### Method `check!` has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open

``````      def check!
check_fail!

return unless WARN_CHECKS[name]

``````
Found in lib/image_optim/bin_resolver/bin.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"

#### Method `value` has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open

``````    def value(worker, options)
value = options.key?(name) ? options[name] : default
if proc
if proc.arity == 2
worker.instance_exec(value, self, &proc)``````
Found in lib/image_optim/option_definition.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"

#### Method `fetch` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

``````    def fetch(original)
return yield unless @cache_dir

digest = digest(original, original.image_format)
cached = @cache_dir / digest``````
Found in lib/image_optim/cache.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"

#### Method `process` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

``````    def process
@src ||= @original
@dst ||= @original.temp_path

return unless yield @src, @dst``````
Found in lib/image_optim/handler.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"

#### Method `init_all` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

``````      def init_all(image_optim, &options_proc)
klasses.map do |klass|
options = options_proc[klass]
next if options[:disable]

``````
Found in lib/image_optim/worker/class_methods.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"

#### Method `full_path` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

``````    def full_path(name)
# PATHEXT is needed only for windows
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
env_path.split(File::PATH_SEPARATOR).each do |dir|
exts.each do |ext|``````
Found in lib/image_optim/bin_resolver.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"