cloudfoundry/cloud_controller_ng

View on GitHub
app/models/runtime/constraints/ports_policy.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

  def verify_ports
    @process.route_mappings.each do |mapping|
      if mapping.app_port.blank?
        return false unless @process.ports.include?(VCAP::CloudController::ProcessModel::DEFAULT_HTTP_PORT)
      elsif mapping.has_app_port_specified? && @process.ports.exclude?(mapping.app_port)
Severity: Minor
Found in app/models/runtime/constraints/ports_policy.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def validate
    return if @process.ports.nil? || @process.ports.empty?
    return @errors.add('Process', 'must have at most 10 exposed ports.') if ports_limit_exceeded?
    return @errors.add('Ports', 'must be integers.') unless all_ports_are_integers?
    return @errors.add('Ports', 'must be in the 1024-65535 range.') unless all_ports_are_in_range?
Severity: Minor
Found in app/models/runtime/constraints/ports_policy.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

Avoid too many return statements within this method.
Open

    return if verify_ports
Severity: Major
Found in app/models/runtime/constraints/ports_policy.rb - About 30 mins to fix

    There are no issues that match your filters.

    Category
    Status