theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

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

  def to_ip_address(name_or_ip)
    return name_or_ip if name_or_ip =~ Net::Validations::IP_REGEXP
    if dns_record(:ptr4)
      lookup = dns_record(:ptr4).dns_lookup(name_or_ip)
      return lookup.ip unless lookup.nil?
Severity: Minor
Found in app/services/nic_ip_resolver.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 os_major has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def os_major
      if os_name == 'Debian' &&
          (facts[:ansible_distribution_major_version][%r{/sid}i] ||
           facts[:ansible_distribution_major_version] == 'n/a')
        debian_os_major_sid
Severity: Minor
Found in app/services/foreman_ansible/operating_system_parser.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 renderer_deprecation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.renderer_deprecation(foreman_version_deadline, method, new_method)
      check_version_format foreman_version_deadline
      called_from_params = false
      caller.each_with_index do |item, index|
        called_from_params = true if item =~ /host_params\.rb.*params/
Severity: Minor
Found in app/services/foreman/deprecation.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 unused_ip has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def unused_ip(subnet, mac = nil)
      params = {}
      params[:mac] = mac if mac.present?

      if subnet.from.present? && subnet.to.present?
Severity: Minor
Found in app/services/proxy_api/dhcp.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 macs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def macs
      unless @macs
        @macs = {}
        facts.each do |fact, value|
          next unless value && fact.to_s =~ /^hwaddr_interfaces/
Severity: Minor
Found in app/services/foreman_salt/fact_parser.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 delivery_settings has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.delivery_settings
    options = {}
    return options unless ['smtp', 'sendmail'].include?(Setting[:delivery_method].to_s)

    prefix = "#{Setting[:delivery_method]}_"
Severity: Minor
Found in app/mailers/application_mailer.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 host_power_ping has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def host_power_ping(result, timeout = DEFAULT_TIMEOUT)
      req_timeout = timeout.nil? || timeout.to_i == 0 ? DEFAULT_TIMEOUT : timeout.to_i
      Timeout.timeout(req_timeout) do
        result.merge!(HOST_POWER[host.supports_power_and_running? ? :on : :off])
      end
Severity: Minor
Found in app/services/power_manager/power_status.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 merged_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def merged_value(key, sorted_lookup_values, options)
        default = key.merge_default ? key.default_value : nil
        case key.key_type
          when "array"
            value = update_array_matcher(default, key.avoid_duplicates, sorted_lookup_values, options)
Severity: Minor
Found in app/services/classification/values_hash_query.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(command_and_args, stdin)
      @stdin = stdin
      @command = command_and_args
      # security checks: ensure no shell, absolute path, permissions and executable
      raise(::Foreman::Exception.new(N_("Command must be array: %s"), command)) unless command.kind_of?(Array)
Severity: Minor
Found in lib/foreman/command_runner.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 select_f has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def select_f(f, attr, array, id, method, select_options = {}, html_options = {})
Severity: Major
Found in app/helpers/form_helper.rb - About 50 mins to fix

    Function PageLayout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const PageLayout = ({
      searchable,
      searchProps,
      searchQuery,
      onSearch,

    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

    Function filter_by_level has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function filter_by_level(item) {
      var level = $(item).val();
    
      // Note that class names don't map to log level names (label-info == notice)
      if (level == 'info') {
    Severity: Minor
    Found in app/assets/javascripts/application.js - 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

    Function ErrorsTree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const ErrorsTree = props => {
      const [expandedNodeNames, setExpandedNodeNames] = React.useState([]);
      const [
        expandedDetailsNodeNames,
        setExpandedDetailsNodeNames,

    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 deeply nested control flow statements.
    Open

              if (attr.val() != null) attrs[attributes[i]] = attr.val();
    Severity: Major
    Found in app/assets/javascripts/application.js - About 45 mins to fix

      Function disableButtonToggle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function disableButtonToggle(item, explicit) {
        if (explicit === undefined) {
          explicit = true;
        }
      
      
      Severity: Minor
      Found in app/assets/javascripts/application.js - 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

      Function NavigationSearch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const NavigationSearch = ({ items, clickAndNavigate }) => {
        let parent = null;
        const navLinksArray = [];
        items.forEach(item => {
          item.subItems.forEach(group => {

      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

      Function makeOnHover has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const makeOnHover = (getIndex, getMoveFnc, direction) => (
        props,
        monitor,
        component
      ) => {

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

        def validate_parameters_names
          names = []
          errors = false
          send(parameters_symbol).each do |param|
            next unless param.new_record? # normal validation would catch this
      Severity: Minor
      Found in app/models/concerns/parameter_validators.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 queue_compute_create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def queue_compute_create
          if find_image.try(:user_data)
            queue.create(:name   => _("Render user data template for %s") % self, :priority => 2,
                         :action => [self, :setUserData])
          end
      Severity: Minor
      Found in app/models/concerns/orchestration/compute.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 handle_migrations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def handle_migrations(type_config, facet_name)
              return unless Foreman.in_setup_db_rake?
              # To prevent running into issues in old migrations when new facet is defined but not migrated yet.
              # We define it only when in migration to avoid this unnecessary checks outside for the migration
              @facet_relation_db_migrate_extensions ||= {} # prevent duplicates
      Severity: Minor
      Found in app/models/concerns/facets/model_extensions_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

      Severity
      Category
      Status
      Source
      Language