nicholasjackson/minke

View on GitHub

Showing 24 of 24 total issues

Method create_and_run_container has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def create_and_run_container args
          # update the timeout for the Excon Http Client
          # set the chunk size to enable streaming of log files
        ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}
        container = ::Docker::Container.create(
Severity: Minor
Found in lib/minke/docker/docker_runner.rb - About 3 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 create_logger has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def self.create_logger(output, verbose = false)
      Logger.new(output).tap do |l|
        l.datetime_format = ''
        l.formatter = proc do |severity, datetime, progname, msg|
          if msg != nil
Severity: Minor
Found in lib/minke/logger.rb - About 3 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 read_task_section has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def read_task_section section, docker_config
        Task.new.tap do |t|
          t.consul_loader = read_consul_loader_section section['consul_loader']  unless section['consul_loader'] == nil
          t.health_check  = read_url section['health_check']                     unless section['health_check'] == nil
          t.docker        = read_docker_section section['docker']                unless section['docker'] == nil
Severity: Minor
Found in lib/minke/config/reader.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 process has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def process config
        replace_variables config.template_location

        replace_variables config.generate_settings.command unless config.generate_settings == nil || config.generate_settings.command == nil
        replace_variables config.generate_settings.docker_file unless config.generate_settings == nil || config.generate_settings.docker_file == nil
Severity: Minor
Found in lib/minke/generators/config_processor.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 read has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def read config_file
        b = binding

        config = Config.new
        file   = ERB.new(File.read(config_file)).result b
Severity: Minor
Found in lib/minke/config/reader.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 run_with_block has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def run_with_block
        success = true

        begin
          @docker_network.create
Severity: Minor
Found in lib/minke/tasks/task.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 read_docker_section has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def read_docker_section section
        DockerSettings.new.tap do |d|
          d.build_image              = section['build_image']              unless section['build_image'] == nil
          d.build_docker_file        = section['build_docker_file']        unless section['build_docker_file'] == nil
          d.application_docker_file  = section['application_docker_file']  unless section['application_docker_file'] == nil
Severity: Minor
Found in lib/minke/config/reader.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_docker_registry has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def read_docker_registry section
        DockerRegistrySettings.new.tap do |d|
          d.url       = section['url'].is_a?(Hash) ? read_secure(section['url']) : section['url']
          d.user      = section['user'].is_a?(Hash) ? read_secure(section['user']) : section['user']
          d.password  = section['password'].is_a?(Hash) ? read_secure(section['password']) : section['password']
Severity: Minor
Found in lib/minke/config/reader.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 create_dependencies has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def create_dependencies task
      project_name = "minke#{SecureRandom.urlsafe_base64(12)}".downcase.gsub(/[^0-9a-z ]/i, '')
      network_name = ENV['DOCKER_NETWORK'] ||= "#{project_name}_default"
      ENV['DOCKER_PROJECT'] = project_name
      ENV['DOCKER_NETWORK'] = network_name
Severity: Minor
Found in lib/minke/command.rb - About 1 hr to fix

Method create_and_run_blocking_container has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def create_and_run_blocking_container args
        host_config = get_port_bindings args
        host_config['NetworkMode'] = @network
        host_config['Binds'] = args[:volumes]

Severity: Minor
Found in lib/minke/docker/docker_runner.rb - About 1 hr to fix

Method run_command_in_container has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def run_command_in_container(command, blocking = false, links = nil, ports = nil)
        begin
          @logger.info "Running command: #{command}"
          settings          = @generator_config.build_settings.docker_settings
          volumes           = settings.binds.clone unless settings.binds == nil
Severity: Minor
Found in lib/minke/tasks/task.rb - About 1 hr to fix

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

      def process generator_name, output_folder
        generator = get_generator generator_name

        # process the files
        @logger.info '# Modifiying templates'
Severity: Minor
Found in lib/minke/generators/processor.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def run args = nil
          @logger.info "## Running cucumber with tags #{args}"

        compose_file = @config.compose_file_for(@task_name)
        compose_file = File.expand_path(compose_file)
Severity: Minor
Found in lib/minke/tasks/cucumber.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 run_command_in_container has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def run_command_in_container(command, blocking = false, links = nil, ports = nil)
        begin
          @logger.info "Running command: #{command}"
          settings          = @generator_config.build_settings.docker_settings
          volumes           = settings.binds.clone unless settings.binds == nil
Severity: Minor
Found in lib/minke/tasks/task.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 build_image has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def build_image dockerfile_dir, name
        ::Docker.options = {:read_timeout => 6200}
        begin
          ::Docker::Image.build_from_dir(dockerfile_dir, {:t => name}) do |v|
            data = /{"stream.*:"(.*)".*/.match(v)
Severity: Minor
Found in lib/minke/docker/docker_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 create_and_run_container has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def create_and_run_container args
          # update the timeout for the Excon Http Client
          # set the chunk size to enable streaming of log files
        ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}
        container = ::Docker::Container.create(
Severity: Minor
Found in lib/minke/docker/docker_runner.rb - About 1 hr to fix

Method run_with_block has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def run_with_block
        success = true

        begin
          @docker_network.create
Severity: Minor
Found in lib/minke/tasks/task.rb - About 1 hr to fix

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

      def read_url section
        URL.new.tap do |url|
          url.address  = section['address']
          url.port     = section['port']     != nil ? section['port'].to_s : '80'
          url.path     = section['path']     != nil ? section['path'] : ''
Severity: Minor
Found in lib/minke/config/reader.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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def compose_file_for section
        file = docker.application_compose_file unless docker.application_compose_file == nil

        if self.send(section) != nil &&
           self.send(section).docker != nil &&
Severity: Major
Found in lib/minke/config/config.rb and 2 other locations - About 45 mins to fix
lib/minke/config/config.rb on lines 118..126
lib/minke/config/config.rb on lines 139..147

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 39.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def build_docker_file_for section
        file = docker.build_docker_file unless docker.build_docker_file == nil

        if self.send(section) != nil &&
           self.send(section).docker != nil &&
Severity: Major
Found in lib/minke/config/config.rb and 2 other locations - About 45 mins to fix
lib/minke/config/config.rb on lines 97..105
lib/minke/config/config.rb on lines 118..126

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 39.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language