manheim/cf_deployer

View on GitHub

Showing 21 of 23 total issues

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

  class ConfigLoader

    def self.erb_to_json filename, config
      json_file = File.join(config[:config_dir], "#{filename}.json")
      raise ApplicationError.new("#{json_file} is missing") unless File.exists?(json_file)
Severity: Minor
Found in lib/cf_deployer/config_loader.rb - About 2 hrs to fix

    Method check_components has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_components validate_inputs
          @config[:components] ||= {}
          return @errors << "At least one component must be defined in config" unless @config[:components].length > 0
          deployable_components = @config[:targets] || []
          component_targets = @config[:components].select { |key, value| deployable_components.include?(key.to_s) }
    Severity: Minor
    Found in lib/cf_deployer/config_validation.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 set_default_settings has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_default_settings
          @config[:components].each do |component_name, component|
            if  component[:'deployment-strategy'] == 'cname-swap'
              component[:settings][:'elb-name-output'] ||= Defaults::ELBName
              component[:settings][:'dns-driver'] ||= Defaults::DNSDriver
    Severity: Minor
    Found in lib/cf_deployer/config_loader.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 deploy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def deploy
          config_dir = @context[:config_dir]
          template = CfDeployer::ConfigLoader.erb_to_json(@component, @context)
          capabilities = @context[:capabilities] || []
          notify = @context[:notify] || []
    Severity: Minor
    Found in lib/cf_deployer/stack.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 wait_for_stack_to_delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def wait_for_stack_to_delete
          Timeout::timeout(900){
            while exists?
              begin
                Log.info "current status: #{stack_status}"
    Severity: Minor
    Found in lib/cf_deployer/stack.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 set_alias_target has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def set_alias_target(hosted_zone_name, target_host_name, elb_hosted_zone_id, elb_dnsname)
            Log.info "set alias target --Hosted Zone: #{hosted_zone_name} --Host Name: #{target_host_name} --ELB DNS Name: #{elb_dnsname} --ELB Zone ID: #{elb_hosted_zone_id}"
            hosted_zone_name = trailing_dot(hosted_zone_name)
            target_host_name = trailing_dot(target_host_name)
            hosted_zone = @aws_route53.hosted_zones.find { |z| z.name == hosted_zone_name }
    Severity: Minor
    Found in lib/cf_deployer/driver/route53_driver.rb - About 1 hr to fix

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

          def output
            @output << table_seperator
            @info.each do |component_name, stacks_hash|
              @output << "\n#{centered(component_name.upcase)}\n"
              @output << table_seperator
      Severity: Minor
      Found in lib/cf_deployer/status_presenter.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 check_hooks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_hooks(component)
            hook_names = [:'before-destroy', :'after-create', :'after-swap']
            hook_names.each do |hook_name|
              next unless component[hook_name] && component[hook_name].is_a?(Hash)
              @errors << "Invalid hook '#{hook_name}'" unless component[hook_name][:file] || component[hook_name][:code]
      Severity: Minor
      Found in lib/cf_deployer/config_validation.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_hook has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def run_hook(hook_name)
              CfDeployer::Driver::DryRun.guard "Skipping hook #{hook_name}" do
                unless @params_and_outputs_resolved
                  target_stack = ( active_stack || stack )
                  unless target_stack.exists?
      Severity: Minor
      Found in lib/cf_deployer/deployment_strategy/base.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 create_stack has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create_stack(template, params, capabilities, tags, notify, create_policy_json)
      Severity: Minor
      Found in lib/cf_deployer/stack.rb - About 45 mins to fix

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

            def check_un_used_inputs(component_name, component)
              component[:inputs].keys.each do |input|
                unless component[:defined_parameters].keys.include?(input) || CommonInputs.include?(input)
                  message = "The input '#{input}' defined in the component '#{component_name}' is not used in the json template as a parameter"
                  if component[:settings][:'raise-error-for-unused-inputs']
        Severity: Minor
        Found in lib/cf_deployer/config_validation.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 update_stack has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def update_stack(template, params, capabilities, tags, override_policy_json)
        Severity: Minor
        Found in lib/cf_deployer/stack.rb - About 35 mins to fix

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

              def instances_status output, component_name, stack_name, instances_hash, in_asg
          Severity: Minor
          Found in lib/cf_deployer/status_presenter.rb - About 35 mins to fix

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

                def resolve_settings
                  inputs.each do |key, value|
                    if(value.is_a?(Hash) && value.key?(:component))
                      dependency = @dependencies.find { |d| d.name == value[:component] }
                      raise "No component '#{value[:component]}' found when attempting to derive input '#{key}'" unless dependency
            Severity: Minor
            Found in lib/cf_deployer/component.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_output_reference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def check_output_reference(setting_name, component_name)
                  setting = @config[:components][component_name][:inputs][setting_name]
                  return unless setting.is_a?(Hash)
                  ref_component_name = setting[:component].to_sym
                  ref_component = @config[:components][ref_component_name]
            Severity: Minor
            Found in lib/cf_deployer/config_validation.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 validate_cli has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def validate_cli cli_options
                    unless File.file?(options[:'config-file'])
                      error_exit "ERROR:  #{options[:'config-file']} is not a file."
                    end
                    error_exit "ERROR:  No environment specified!" unless @environment
            Severity: Minor
            Found in lib/cf_deployer/cli.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 check_parameters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def check_parameters(component_name, component)
                  component[:defined_parameters] ||= {}
                  component[:defined_outputs] ||= {}
                  component[:defined_parameters].each do | parameter_name, parameter |
                    if component[:inputs].keys.include?(parameter_name) || parameter[:Default]
            Severity: Minor
            Found in lib/cf_deployer/config_validation.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 warm_up_stack has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def warm_up_stack stack, previous_stack = nil, adjust_min_max = false
                    previous_ids = previous_stack ? template_asg_name_to_ids(previous_stack) : {}
                    template_asg_name_to_ids(stack).each do |name, id|
                      driver = asg_driver(id)
                      description = asg_driver(previous_ids[name] || id).describe
            Severity: Minor
            Found in lib/cf_deployer/deployment_strategy/base.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 check_application_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def check_application_name
                  @config[:application] = "" unless @config[:application]
                  return @errors << "Application name is missing in config" unless @config[:application].length > 0
                  @errors << "Application name cannot be longer than 100 and can only contain letters, numbers, '-' and '.'" unless @config[:application] =~ /^[a-zA-Z0-9\.-]{1,100}$/
                end
            Severity: Minor
            Found in lib/cf_deployer/config_validation.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 filter_for_verbosity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def filter_for_verbosity info_hash
                  if @verbosity == 'stacks'
                    info_hash.each do |component, component_hash|
                      component_hash.each { |stack, stack_hash| stack_hash.delete :resources }
                    end
            Severity: Minor
            Found in lib/cf_deployer/status_presenter.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