theforeman/foreman

View on GitHub
app/controllers/concerns/foreman/controller/smart_proxy_auth.rb

Summary

Maintainability
C
1 day
Test Coverage

Method auth_smart_proxy has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def auth_smart_proxy(proxies = SmartProxy.unscoped.all, require_cert = true)
    request_hosts = nil
    if request.ssl?
      # If we have the client certficate in the request environment we can extract the dn and sans from there
      # if not we use the dn in the request environment
Severity: Minor
Found in app/controllers/concerns/foreman/controller/smart_proxy_auth.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 detect_matching_host has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def detect_matching_host(allowed_hosts, request_hosts)
    allowed_hosts.product(request_hosts).each do |allowed, request|
      if request.starts_with?('*')
        # certificate wildcard name
        rex = /\A#{Regexp.escape(request).sub('\\*', '.*')}\Z/
Severity: Minor
Found in app/controllers/concerns/foreman/controller/smart_proxy_auth.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 auth_smart_proxy has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def auth_smart_proxy(proxies = SmartProxy.unscoped.all, require_cert = true)
    request_hosts = nil
    if request.ssl?
      # If we have the client certficate in the request environment we can extract the dn and sans from there
      # if not we use the dn in the request environment
Severity: Minor
Found in app/controllers/concerns/foreman/controller/smart_proxy_auth.rb - About 1 hr to fix

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

      def require_smart_proxy_or_login(features = nil)
        features = features.call if features.respond_to?(:call)
        allowed_smart_proxies = if features.blank?
                                  SmartProxy.unscoped.all
                                else
    Severity: Minor
    Found in app/controllers/concerns/foreman/controller/smart_proxy_auth.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

    There are no issues that match your filters.

    Category
    Status