toy/image_optim

View on GitHub

Showing 22 of 22 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)
Severity: Minor
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"

Further reading

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)
Severity: Minor
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"

Further reading

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

      def optimize(src, dst, options = {})
        if jpegrescan
          args = %W[
            #{src}
            #{dst}
Severity: Minor
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"

Further reading

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

      def optimize(src, dst, options = {})
        args = %W[
          -k#{copy_chunks ? 1 : 0}
          -s#{strategy}
          -q
Severity: Minor
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"

Further reading

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.fetch(env_name, nil)
      return unless path

Severity: Minor
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"

Further reading

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

    def resolve!(name)
      name = name.to_sym

      resolving(name) do
        path = symlink_custom_bin!(name) || full_path(name)
Severity: Minor
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"

Further reading

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

      def optimize(src, dst, options = {})
        args = %W[
          --output=#{dst}
          --no-comments
          --no-names
Severity: Minor
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"

Further reading

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}"
Severity: Minor
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"

Further reading

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

      def run(*args)
        if args.last.is_a?(Hash) && (timeout = args.last.delete(:timeout))
          args.last[Gem.win_platform? ? :new_pgroup : :pgroup] = true

          pid = Process.spawn(*args)
Severity: Minor
Found in lib/image_optim/cmd.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 optimize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def optimize(src, dst, options = {})
        src.copy(dst)
        args = %W[
          -o #{level}
          -quiet
Severity: Minor
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"

Further reading

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

  def optimize_image(original)
    original = Path.convert(original)
    return unless (workers = workers_for_image(original))

    optimized = @cache.fetch(original) do
Severity: Minor
Found in lib/image_optim.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 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

Severity: Minor
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"

Further reading

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

    def initialize(name, default, type_or_description, description = nil, &proc)
Severity: Minor
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)
    Severity: Minor
    Found in lib/image_optim/worker/class_methods.rb - About 35 mins to fix

      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)
      Severity: Minor
      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"

      Further reading

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

            def check!
              check_fail!
      
              return unless WARN_CHECKS[name]
      
      
      Severity: Minor
      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"

      Further reading

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

            def optimize(src, dst, options = {})
              src.copy(dst)
              args = %W[
                -o #{level}
                --quiet
      Severity: Minor
      Found in lib/image_optim/worker/oxipng.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 wrapped_text has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def wrapped_text(text, wrapped_width, wrapped_indent, columns)
              wrapped = []
              text.split("\n").each do |line|
                if line.length <= columns
                  wrapped << line << "\n"
      Severity: Minor
      Found in lib/image_optim/runner/option_parser.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 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|
      Severity: Minor
      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"

      Further reading

      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
      Severity: Minor
      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"

      Further reading

      Severity
      Category
      Status
      Source
      Language