toy/image_optim

View on GitHub

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

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 11 (exceeds 5 allowed). Consider refactoring.
Open

      def optimize(src, dst)
        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 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 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 optimize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def optimize(src, dst)
        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 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
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 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 help has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def help
        text = super

        # reserve one column
        columns = terminal_columns - 1
Severity: Minor
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"

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

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

      Further reading

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

      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

      Severity
      Category
      Status
      Source
      Language