moneybird/dockistrano

View on GitHub

Showing 15 of 15 total issues

Class Service has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Service

    attr_reader :dependencies, :config, :image_name, :registry,
      :tag, :test_command, :provides_env, :backing_service_env,
      :data_directories, :environment, :host, :additional_commands,
Severity: Minor
Found in lib/dockistrano/service.rb - About 5 hrs to fix

    File service.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'yaml'
    require 'net/http'
    
    module Dockistrano
    
    
    Severity: Minor
    Found in lib/dockistrano/service.rb - About 3 hrs to fix

      Class Docker has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Docker
      
          class EnvironmentVariableMissing < StandardError
          end
      
      
      Severity: Minor
      Found in lib/dockistrano/docker.rb - About 2 hrs to fix

        Method execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.execute(command, mode=:string_result)
              case mode
              when :string_result
                Dockistrano::CommandLine.command_with_result("#{docker_command} #{command.collect { |c| c.kind_of?(String) ? c : arguments(c) }.join(" ")}".strip)
              when :stream
        Severity: Minor
        Found in lib/dockistrano/docker.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 status has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def status
              say "DOCKISTRANO_ENVIRONMENT: #{options["environment"]}", :green
              say "DOCKER_HOST_IP: #{ENV['DOCKER_HOST_IP']}", :green
              say "DOCKER_BINARY: #{ENV['DOCKER_BINARY']}", :green
              say ""
        Severity: Minor
        Found in lib/dockistrano/cli.rb - About 1 hr to fix

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

              def config=(config)
                @config = config
                @dependencies = config["dependencies"] || {}
                @image_name ||= (config["image_name"] || Git.repository_name).gsub(/\-/, "_").gsub(/\./, "")
                @tag ||= config["tag"] || Git.branch
          Severity: Minor
          Found in lib/dockistrano/service.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 arguments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.arguments(options)
                options.collect do |k,v|
                  case v
                  when TrueClass
                    "-#{k}"
          Severity: Minor
          Found in lib/dockistrano/docker.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 update_hipache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_hipache(server_up=true)
                if !host.nil? and (redis_url = backing_services["hipache"].ip_address)
                  hipache = Hipache.new("redis://#{redis_url}:6379")
                  host.each do |hostname, port|
                    if server_up
          Severity: Minor
          Found in lib/dockistrano/service.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 load_from_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def load_from_image
                raw_config = Docker.run(backing_service.full_image_name, command: "cat /dockistrano.yml", rm: true)
                if raw_config.empty? or raw_config.include?("No such file or directory")
                  if raw_config.include?("failed to mount")
                    raise HostDirectoriesMissing
          Severity: Minor
          Found in lib/dockistrano/service_dependency.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

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

              def reset
                CommandLine.command_with_result("mkdir -p #{directories_required_on_host}")
                if reset_command
                  ensure_backing_services
                  create_data_directories
          Severity: Minor
          Found in lib/dockistrano/service.rb and 1 other location - About 15 mins to fix
          lib/dockistrano/service.rb on lines 337..342

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

          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 2 locations. Consider refactoring.
          Open

              def setup
                CommandLine.command_with_result("mkdir -p #{directories_required_on_host}")
                if setup_command
                  ensure_backing_services
                  create_data_directories
          Severity: Minor
          Found in lib/dockistrano/service.rb and 1 other location - About 15 mins to fix
          lib/dockistrano/service.rb on lines 346..351

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

          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 2 locations. Consider refactoring.
          Open

              def setup
                current_service.backing_services.each do |name, service|
                  service.setup
                  say_status "Done", "Setting up #{service.image_name}", :green
                end
          Severity: Minor
          Found in lib/dockistrano/cli.rb and 1 other location - About 15 mins to fix
          lib/dockistrano/cli.rb on lines 30..37

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

          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 2 locations. Consider refactoring.
          Open

              def reset
                current_service.backing_services.each do |name, service|
                  service.reset
                  say_status "Done", "Reset #{service.image_name}", :green
                end
          Severity: Minor
          Found in lib/dockistrano/cli.rb and 1 other location - About 15 mins to fix
          lib/dockistrano/cli.rb on lines 19..26

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

          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 2 locations. Consider refactoring.
          Open

                when :stream
                  Dockistrano::CommandLine.command_with_stream("#{docker_command} #{command.collect { |c| c.kind_of?(String) ? c : arguments(c) }.join(" ")}".strip)
          Severity: Minor
          Found in lib/dockistrano/docker.rb and 1 other location - About 15 mins to fix
          lib/dockistrano/docker.rb on lines 35..36

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

          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 2 locations. Consider refactoring.
          Open

                when :string_result
                  Dockistrano::CommandLine.command_with_result("#{docker_command} #{command.collect { |c| c.kind_of?(String) ? c : arguments(c) }.join(" ")}".strip)
          Severity: Minor
          Found in lib/dockistrano/docker.rb and 1 other location - About 15 mins to fix
          lib/dockistrano/docker.rb on lines 37..38

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

          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