theforeman/foreman

View on GitHub

Showing 1,254 of 1,254 total issues

File compute.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'socket'
require 'timeout'

module Orchestration::Compute
  extend ActiveSupport::Concern
Severity: Minor
Found in app/models/concerns/orchestration/compute.rb - About 3 hrs to fix

    Function ColumnSelector has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    const ColumnSelector = props => {
      const {
        data: { url, controller, categories, hasPreference },
      } = props;
    
    

    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

    File TableIndexPage.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable max-lines */
    import React, { useMemo } from 'react';
    import PropTypes from 'prop-types';
    import { QuestionCircleIcon } from '@patternfly/react-icons';
    import { useHistory } from 'react-router-dom';

      File operatingsystem.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'ostruct'
      require 'uri'
      
      class Operatingsystem < ApplicationRecord
        audited
      Severity: Minor
      Found in app/models/operatingsystem.rb - About 3 hrs to fix

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

        export const useLocalStorage = (key, defaultValue, session = false) => {
          const storage = useRef(session ? sessionStorage : localStorage);
          const [value, setValue] = useState(() =>
            getStorageValue(key, defaultValue, storage)
          );
        webpack/assets/javascripts/react_app/components/common/DateTimePicker/TimeComponents/PickTimeClock.js on lines 84..103

        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 106.

        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

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

            render(
              <Provider store={store}>
                <Table
                  columns={columns}
                  params={{ page: 1, perPage: 10, order: '' }}
        webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/Table/Table.test.js on lines 136..149

        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 105.

        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

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

            render(
              <Provider store={store}>
                <Table
                  columns={columns}
                  params={{ page: 1, perPage: 10, order: '' }}
        webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/Table/Table.test.js on lines 115..128

        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 105.

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

              def search_by_os_minor(key, operator, value)
                y, z = value.split(".")
                z ||= 0
                operatingsystem_ids = []
                Operatingsystem.where.not(minor: [nil, '']).find_each do |os|
        Severity: Minor
        Found in app/models/concerns/hostext/search.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 useBulkSelect has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        export const useBulkSelect = ({
          results,
          metadata,
          initialArry = [],
          initialExclusionArry = [],

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

          def self.method_missing(method, *args, **kwargs, &block)
            type = "Host::Managed"
            case method.to_s
            when /create/, 'new'
              # in this case args should contain a hash with host attributes
        Severity: Minor
        Found in app/models/host.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

        File PersonalAccessTokenModal.js has 309 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-disable max-lines */
        import React, { useState } from 'react';
        import { useDispatch, useSelector } from 'react-redux';
        import {
          DatePicker,

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

          test('Toggle TimeTable minute from PickTimeClock', () => {
            const time = new Date('2/21/2019 , 12:22:31 PM');
            const toggleTimeTable = jest.fn();
            const component = mount(
              <PickTimeClock time={time} toggleTimeTable={toggleTimeTable} />
          webpack/assets/javascripts/react_app/components/common/DateTimePicker/TimeComponents/PickTimeClock.test.js on lines 51..60

          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 103.

          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

          test('Toggle TimeTable hour from PickTimeClock', () => {
            const time = new Date('2/21/2019 , 12:22:31 PM');
            const toggleTimeTable = jest.fn();
            const component = mount(
              <PickTimeClock time={time} toggleTimeTable={toggleTimeTable} />
          webpack/assets/javascripts/react_app/components/common/DateTimePicker/TimeComponents/PickTimeClock.test.js on lines 62..71

          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 103.

          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 index.js has 308 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* eslint-disable max-lines */
          import React, { useState, useEffect, useCallback } from 'react';
          import { useSelector, useDispatch } from 'react-redux';
          
          import {

            fixtures has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            const fixtures = {
              'should return editor': () => selectEditor(state),
              'should return selected host': () => selectChosenHost(state),
              'should return selectPreviewResult': () => selectPreviewResult(state),
              'should return selectErrorText': () => selectErrorText(state),

              Class LookupKey has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class LookupKey < ApplicationRecord
                audited :associated_with => :audit_class
                include Authorizable
                include HiddenValue
                include Classification
              Severity: Minor
              Found in app/models/lookup_keys/lookup_key.rb - About 3 hrs to fix

                Class ComputeResourcesController has 28 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class ComputeResourcesController < V2::BaseController
                      include Api::Version2
                      include Foreman::Controller::Parameters::ComputeResource
                
                      wrap_parameters ComputeResource, :include => compute_resource_params_filter.accessible_attributes(parameter_filter_context)
                Severity: Minor
                Found in app/controllers/api/v2/compute_resources_controller.rb - About 3 hrs to fix

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

                              {subnet6ID && (
                                <DescriptionListGroup>
                                  <DescriptionListTerm>{__('IPv6 subnet')}</DescriptionListTerm>
                                  <DescriptionListDescription>
                                    <Button
                  webpack/assets/javascripts/react_app/components/HostDetails/Tabs/Details/Cards/NetworkingInterfaces/NICDescriptionList.js on lines 94..109

                  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 101.

                  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

                              {subnetID && (
                                <DescriptionListGroup>
                                  <DescriptionListTerm>{__('Subnet')}</DescriptionListTerm>
                                  <DescriptionListDescription>
                                    <Button
                  webpack/assets/javascripts/react_app/components/HostDetails/Tabs/Details/Cards/NetworkingInterfaces/NICDescriptionList.js on lines 110..125

                  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 101.

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

                      def nested_attribute_for(*fields)
                        @nested_attribute_fields = fields
                        @nested_attribute_fields.each do |field|
                          # Example method
                          # def inherited_compute_profile_id
                  Severity: Minor
                  Found in app/models/concerns/nested_ancestry_common.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

                  Severity
                  Category
                  Status
                  Source
                  Language