theforeman/foreman

View on GitHub
app/services/foreman/renderer/scope/macros/base.rb

Summary

Maintainability
C
7 hrs
Test Coverage

File base.rb has 423 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Foreman
  module Renderer
    module Scope
      module Macros
        module Base
Severity: Minor
Found in app/services/foreman/renderer/scope/macros/base.rb - About 6 hrs to fix

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

              def foreman_server_ca_cert(server_ca_file_enabled: true, ssl_ca_file_enabled: true)
                setting_values = []
                setting_values << Setting[:server_ca_file] if server_ca_file_enabled
                setting_values << Setting[:ssl_ca_file] if ssl_ca_file_enabled
    
    
    Severity: Minor
    Found in app/services/foreman/renderer/scope/macros/base.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 save_to_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def save_to_file(filename, content, verbatim: false)
                delimiter = 'EOF-' + Digest::SHA512.hexdigest(filename)[0..7]
                if content.empty?
                  "cp /dev/null #{filename}"
                elsif verbatim
    Severity: Minor
    Found in app/services/foreman/renderer/scope/macros/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 indent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def indent(count, skip1: false)
                return unless block_given? && (text = yield.to_s)
                prefix = ' ' * count
                result = []
                text.each_line.with_index do |line, line_no|
    Severity: Minor
    Found in app/services/foreman/renderer/scope/macros/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

    There are no issues that match your filters.

    Category
    Status