theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Function SearchBar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const SearchBar = ({
  data: {
    autocomplete: { url, searchQuery, apiParams } = { url: '' },
    controller,
    bookmarks,
Severity: Minor
Found in webpack/assets/javascripts/react_app/components/SearchBar/index.js - 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

Function subnetCidrChanged has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function subnetCidrChanged(field) {
  var cidr = field.val();
  var mask_field = $('#subnet_mask');
  clearError(field);
  if (isBlank(cidr)) {
Severity: Minor
Found in app/assets/javascripts/subnets.js - 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 set_realm has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def set_realm(options = {})
    initialize_realm
    logger.info "#{options[:update] ? 'Update' : 'Add'} realm entry for #{options[:rebuild] ? 'reprovisioned' : 'new'} host #{name}"
    options[:hostname]  = name
    options[:userclass] = hostgroup.title unless hostgroup.nil?
Severity: Minor
Found in app/models/concerns/orchestration/realm.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

Function SelectAllCheckbox has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const SelectAllCheckbox = ({
  selectNone,
  selectDefault,
  selectPage,
  selectedCount,

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

    def host_inherited_params_objects
      params = CommonParameter.all
      params += extract_params_from_object_ancestors(organization) if organization
      params += extract_params_from_object_ancestors(location) if location
      params += domain.domain_parameters.authorized(:view_params) if domain
Severity: Minor
Found in app/models/concerns/host_params.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 authenticate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def authenticate(login = account, password = account_password)
    return if login.blank? || password.blank?

    logger.debug "LDAP auth with user #{login} against #{self}"

Severity: Minor
Found in app/models/auth_sources/auth_source_ldap.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 fog_credentials has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def fog_credentials
      { :provider           => :openstack,
        :openstack_api_key  => password,
        :openstack_username => user,
        :openstack_auth_url => url_for_fog,
Severity: Minor
Found in app/models/compute_resources/foreman/model/openstack.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 build_required_interfaces has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def build_required_interfaces(attrs = {})
      if primary_interface.nil?
        if interfaces.empty?
          attrs[:type] ||= 'Nic::Managed'
          interfaces.build(attrs.merge(primary: true))
Severity: Minor
Found in app/models/host/base.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 set_interfaces has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def set_interfaces(parser)
      # if host has no information in primary interface we try to match it and update it
      # instead of creating new interface, suggested primary interface mac and identifier
      # is saved to primary interface so we match it in updating code below
      if !managed? && primary_interface.mac.blank? && primary_interface.identifier.blank?
Severity: Minor
Found in app/models/host/base.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 execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def execute
    Foreman::AdvisoryLockManager.with_transaction_lock(ADVISORY_LOCK) do
      # if we had to wait for the lock it is likely that the seeding has already been done, no need to seed again
      return unless hash_changed?

Severity: Minor
Found in app/services/foreman_seeder.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 find_collection has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def find_collection(resource_class, options = {})
    permission = options.delete :permission
    resource_class = Host if resource_class == Host::Base

    Foreman::Logging.logger('permissions').debug "checking permission #{permission} for class #{resource_class}"
Severity: Minor
Found in app/services/authorizer.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 get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def get(path = nil, payload = {})
      query = payload.delete(:query)
      Foreman::Deprecation.deprecation_warning("3.3", "passing additional headers to ProxyApi resource GET action") unless payload.empty?
      final_uri = path || ""
      if query
Severity: Minor
Found in app/services/proxy_api/resource.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 ip_exists has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def ip_exists(ip, subnet, group = "")
      raise "subnet cannot be nil" if subnet.nil?
      raise "ip cannot be nil" if ip.nil?
      response = parse get("/subnet/#{subnet}/#{ip}", query: { group: group })
      raise(response['error']) if response.is_a?(Hash) && response['error'].present?
Severity: Minor
Found in app/services/proxy_api/external_ipam.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 build_scopes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def build_scopes(model, ignore: [], assoc_name: nil)
      scopes = dependent_associations(model).map do |assoc|
        next if ignore.include?(assoc.name)

        dep_associations = dependent_associations(assoc.klass)
Severity: Minor
Found in app/services/foreman/preload_scopes_builder.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

Function computeResourceSelected has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function computeResourceSelected(item) {
  providerSpecificNICInfo = null;
  var compute = $(item).val();
  if (compute == '' && /compute_resource/.test($(item).attr('name'))) {
    //Bare metal compute resource
Severity: Minor
Found in app/assets/javascripts/host_edit.js - About 1 hr to fix

    Method base_host_title_actions has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def base_host_title_actions(host)
        [
          {
            :action => button_group(
              link_to_if_authorized(_("Edit"), hash_for_edit_host_path(:id => host).merge(:auth_object => host),
    Severity: Minor
    Found in app/helpers/host_description_helper.rb - About 1 hr to fix

      Function load_dynamic_javascripts has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function load_dynamic_javascripts(html) {
        function waitForAllLoaded() {
          // Wait for all plugins js modules to be loaded before loading the javascript content
          return new Promise(function(resolve) {
            // window.allPluginsLoaded is set to {} when plugins are starting to load
      Severity: Minor
      Found in app/assets/javascripts/late_load.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

            return log_orchestration_errors unless (dns? || dns6? || reverse_dns? || reverse_dns6? || old&.dns? || old&.dns6? || old&.reverse_dns? || old&.reverse_dns6?) && errors.empty?
        Severity: Critical
        Found in app/models/concerns/orchestration/dns.rb - About 1 hr to fix

          Function getColumns has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const getColumns = (fetchReports, origin) => {
            const columns = [
              {
                title: __('Reported at'),
                formatter: reportToShowFormatter,

            Function testConnection has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function testConnection(item) {
              let crId = $('form').data('id');
            
              if (crId === undefined || crId === null) {
                crId = '';
            Severity: Minor
            Found in webpack/assets/javascripts/foreman_compute_resource.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language