manheim/cf_deployer

View on GitHub
lib/cf_deployer/config_validation.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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 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 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 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 check_cname_swap_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def check_cname_swap_options(component)
      @errors << "dns-fqdn is required when using cname-swap deployment-strategy" unless component[:settings][:'dns-fqdn']
      @errors << "dns-zone is required when using cname-swap deployment-strategy" unless component[:settings][:'dns-zone']
      @errors << "'#{component[:settings][:'elb-name-output']}' is not a CF stack output, which is required by cname-swap deployment" unless component[:defined_outputs].keys.include?(component[:settings][:'elb-name-output'].to_sym)
    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 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 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

There are no issues that match your filters.

Category
Status