theforeman/foreman

View on GitHub

Showing 1,254 of 1,254 total issues

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

    def sanitize_inherited_vm_attributes(args, template, instance_type)
      # Override memory an cores values if template and/or instance type is/are provided.
      # Take template values if blank values for VM attributes, because oVirt will fail if empty values are present in VM definition
      # Instance type values always take precedence on templates or vm provided values
      if template
Severity: Minor
Found in app/models/compute_resources/foreman/model/ovirt.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 process has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def process(queue_name)
    processed = 0
    return true if skip_orchestration?

    # queue is empty - nothing to do.
Severity: Minor
Found in app/models/concerns/orchestration.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 base_host_overview_fields has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def base_host_overview_fields(host)
    fields = []
    fields << { :field => [_("Build duration"), build_duration(host)], :priority => 90 }
    fields << { :field => [_("Build errors"), link_to("Logs from OS installer", build_errors_host_path(:id => host.id))], :priority => 91 } if host.build_errors.present?
    fields << { :field => [_("Token"), host.token || _("N/A")], :priority => 92 } if User.current.admin
Severity: Minor
Found in app/helpers/host_description_helper.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 interfaces has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def interfaces
      interfaces = {}

      facts.each do |fact, value|
        next unless value && fact.to_s =~ /^ip_interfaces/
Severity: Minor
Found in app/services/foreman_salt/fact_parser.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

Function render has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const {
      breadcrumbItems,
      isSwitchable,
      resource,

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    const fixtures = {
      'selects HostStatusesNames': () => selectHostStatusesNames(store),
      'selects HostStatusDetails': () => selectHostStatusDetails(store, statusName),
      'selects HostStatusDescription': () => selectHostStatusDescription(store, statusName),
      'selects selectHostStatusTotalPaths': () => selectHostStatusTotalPaths(store, statusName),
    webpack/assets/javascripts/react_app/redux/API/__tests__/APISelectors.test.js on lines 34..48

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 98.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    const fixtures = {
      'should return the API wrapper': () => selectAPI(successState),
      'should return the API substate by key': () =>
        selectAPIByKey(successState, key),
      'should return the API substate status': () =>
    webpack/assets/javascripts/react_app/components/HostStatuses/HostStatusesSelectors.test.js on lines 17..25

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 98.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        const {
          breadcrumbItems,
          isSwitchable,
          resource,
          currentPage,
    webpack/assets/javascripts/react_app/components/Editor/components/EditorModal.js on lines 9..29

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    const EditorModal = ({
      changeDiffViewType,
      changeEditorValue,
      diffViewType,
      editorValue,
    webpack/assets/javascripts/react_app/components/BreadcrumbBar/BreadcrumbBar.js on lines 33..53

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method setup_roles! has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

          def setup_roles!
            return false if Foreman.in_setup_db_rake? || !permission_table_exists? || User.unscoped.find_by_login(User::ANONYMOUS_ADMIN).nil?
            Role.without_auditing do
              Filter.without_auditing do
                default_roles.each do |name, permissions|
    Severity: Minor
    Found in app/registries/foreman/plugin/rbac_registry.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 auth_smart_proxy has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def auth_smart_proxy(proxies = SmartProxy.unscoped.all)
        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

    Function interface_subnet_selected has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function interface_subnet_selected(element, ip_field, skip_mac) {
      // mark the selected value to preserve it for form hiding
      preserve_selected_options($(element));
    
      if ($(element).attr('disabled')) return;
    Severity: Major
    Found in app/assets/javascripts/host_edit.js - About 3 hrs to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

                <GridItem span={2} rowSpan={2} className="text-center">
                  <div style={{ fontSize: '1.5em' }}>
                    <GlobalStatusIcon status={0} />
                  </div>
                  <Skeleton />
      webpack/assets/javascripts/react_app/components/HostStatuses/Status/StatusSkeleton.js on lines 33..40
      webpack/assets/javascripts/react_app/components/HostStatuses/Status/StatusSkeleton.js on lines 41..48

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

                <GridItem span={2} rowSpan={2} className="text-center">
                  <div style={{ fontSize: '1.5em' }}>
                    <GlobalStatusIcon status={1} />
                  </div>
                  <Skeleton />
      webpack/assets/javascripts/react_app/components/HostStatuses/Status/StatusSkeleton.js on lines 25..32
      webpack/assets/javascripts/react_app/components/HostStatuses/Status/StatusSkeleton.js on lines 41..48

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

                <GridItem span={2} rowSpan={2} className="text-center">
                  <div style={{ fontSize: '1.5em' }}>
                    <GlobalStatusIcon status={2} />
                  </div>
                  <Skeleton />
      webpack/assets/javascripts/react_app/components/HostStatuses/Status/StatusSkeleton.js on lines 25..32
      webpack/assets/javascripts/react_app/components/HostStatuses/Status/StatusSkeleton.js on lines 33..40

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          <FormGroup
            label={__('Repository GPG key URL')}
            fieldId="reg_gpg_key_url"
            labelIcon={
              <LabelIcon
      webpack/assets/javascripts/react_app/routes/RegistrationCommands/RegistrationCommandsPage/components/fields/Repository.js on lines 18..37

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          <FormGroup
            label={__('Repository')}
            fieldId="reg_repo"
            labelIcon={
              <LabelIcon
      webpack/assets/javascripts/react_app/routes/RegistrationCommands/RegistrationCommandsPage/components/fields/Repository.js on lines 38..57

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      File Editor.js has 293 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React from 'react';
      import PropTypes from 'prop-types';
      import { ToastNotification } from 'patternfly-react';
      
      import { noop } from '../../common/helpers';
      Severity: Minor
      Found in webpack/assets/javascripts/react_app/components/Editor/Editor.js - About 3 hrs to fix

        Class TaxHost has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class TaxHost
          FOREIGN_KEYS = [:location_id, :organization_id, :hostgroup_id,
                          :domain_id, :medium_id, :subnet_id,
                          :compute_resource_id, :realm_id, :ptable_id]
        
        
        Severity: Minor
        Found in app/services/tax_host.rb - About 3 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          test('TimeInput toggles view to minutes', () => {
            const time = new Date('2019-01-04   14:22:31');
            const component = mount(<TimeInput time={time} />);
            component
              .find('.timepicker-minute')
          webpack/assets/javascripts/react_app/components/common/DateTimePicker/TimeComponents/TimeInput.test.js on lines 11..19

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 95.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language