theforeman/foreman

View on GitHub

Showing 1,256 of 1,256 total issues

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

                  group.groupItems.map(
                    ({
                      id,
                      title: subItemTitle,
                      className: subItemClassName,
webpack/assets/javascripts/react_app/components/Layout/Navigation.js on lines 212..236

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

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

Class Template has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

class Template < ApplicationRecord
  include Exportable
  attr_accessor :modify_locked, :modify_default

  has_many :template_inputs, :dependent => :destroy, :foreign_key => 'template_id', :autosave => true
Severity: Minor
Found in app/models/template.rb - About 5 hrs to fix

    Function PersonalAccessTokenModal has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    const PersonalAccessTokenModal = ({ controller, url }) => {
      const dispatch = useDispatch();
      const [isModalOpen, setIsModalOpen] = useState(false);
      const [endsNever, setEndsNever] = useState(true);
      const [isDateTimeDisabled, setIsDateTimeDisabled] = useState(true);

    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

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

      editor: {
        hosts: [],
        filteredHosts: [],
        diffViewType: 'split',
        editorName: 'editor',
    Severity: Major
    Found in webpack/assets/javascripts/react_app/common/testHelpers.js and 1 other location - About 5 hrs to fix
    webpack/assets/javascripts/react_app/components/Editor/EditorReducer.js on lines 30..61

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

    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 initialState = Immutable({
      [EDITOR_HOST_ARR]: [],
      [EDITOR_HOST_FILTERED_ARR]: [],
      diffViewType: 'split',
      editorName: 'editor',
    webpack/assets/javascripts/react_app/common/testHelpers.js on lines 194..225

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

    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 plugin.rb has 405 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_dependency 'foreman/plugin/logging'
    require_dependency 'foreman/plugin/report_scanner_registry'
    require_dependency 'foreman/plugin/report_origin_registry'
    require_dependency 'foreman/plugin/medium_providers_registry'
    require_dependency 'foreman/plugin/fact_importer_registry'
    Severity: Minor
    Found in app/registries/foreman/plugin.rb - About 5 hrs to fix

      File hosts_controller.rb has 405 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Api
        module V2
          class HostsController < V2::BaseController
            include Api::Version2
            include Api::V2::BulkHostsExtension
      Severity: Minor
      Found in app/controllers/api/v2/hosts_controller.rb - About 5 hrs to fix

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

          it('should render custom breadcrumbs', () => {
            const customBreadcrumbs = <div>test Breadcrumbs</div>;
            const { getByText } = render(
              <Provider store={store}>
                <Router>
        webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.test.js on lines 78..95

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

        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

          it('should render toolbar buttons', () => {
            const toolbarButtons = <button>test Button</button>;
            const { getByText } = render(
              <Provider store={store}>
                <Router>
        webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.test.js on lines 59..76

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

        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('PickTimeTable is working properly for Hour', () => {
          const time = new Date('2019-01-04   14:22:31');
          const setSelected = jest.fn();
          const component = shallow(
            <PickTimeTable time={time} type={HOUR} setSelected={setSelected} />
        webpack/assets/javascripts/react_app/components/common/DateTimePicker/TimeComponents/PickTimeTable.test.js on lines 6..18

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

        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('PickTimeTable is working properly for Minute', () => {
          const time = new Date('2019-01-04   14:22:31');
          const setSelected = jest.fn();
          const component = shallow(
            <PickTimeTable time={time} type={MINUTE} setSelected={setSelected} />
        webpack/assets/javascripts/react_app/components/common/DateTimePicker/TimeComponents/PickTimeTable.test.js on lines 20..32

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

        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 hosts_helper.rb has 389 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module HostsHelper
          include OperatingsystemsHelper
          include HostsAndHostgroupsHelper
          include ComputeResourcesVmsHelper
          include HostsNicHelper
        Severity: Minor
        Found in app/helpers/hosts_helper.rb - About 5 hrs to fix

          Class ApplicationController has 40 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ApplicationController < ActionController::Base
            include ApplicationShared
          
            include Foreman::Controller::Flash
            include Foreman::Controller::Authorize
          Severity: Minor
          Found in app/controllers/application_controller.rb - About 5 hrs to fix

            File model_attributes.rb has 387 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            _('Architecture')
            # TRANSLATORS: "Table name" or "Table name|Column name" for error messages
            _('Architecture|Name')
            # TRANSLATORS: "Table name" or "Table name|Column name" for error messages
            _('Audit')
            Severity: Minor
            Found in locale/model_attributes.rb - About 5 hrs to fix

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

              const UpdatePackages = ({
                updatePackages,
                handleUpdatePackages,
                isLoading,
              }) => (
              webpack/assets/javascripts/react_app/routes/RegistrationCommands/RegistrationCommandsPage/components/fields/Insecure.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 139.

              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 Insecure = ({ insecure, handleInsecure, isLoading }) => (
                <FormGroup fieldId="reg_insecure">
                  <Checkbox
                    ouiaId="reg_insecure"
                    label={
              webpack/assets/javascripts/react_app/routes/RegistrationCommands/RegistrationCommandsPage/components/fields/UpdatePackages.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 139.

              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

              export const buildHost = hostId => dispatch => {
                const successToast = () =>
                  sprintf(__('Host %s will be built next boot'), hostId);
                const errorToast = ({ message }) => message;
                const url = foremanUrl(`/hosts/${hostId}/setBuild`);
              webpack/assets/javascripts/react_app/components/HostDetails/ActionsBar/actions.js on lines 92..106

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

              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

              export const cancelBuild = hostId => dispatch => {
                const successToast = () =>
                  sprintf(__('Canceled pending build for %s'), hostId);
                const errorToast = ({ message }) => message;
                const url = foremanUrl(`/hosts/${hostId}/cancelBuild`);
              webpack/assets/javascripts/react_app/components/HostDetails/ActionsBar/actions.js on lines 76..90

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

              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

              Class Libvirt has 38 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Libvirt < ComputeResource
                  include ComputeResourceConsoleCommon
              
                  ALLOWED_DISPLAY_TYPES = %w(vnc spice)
              
              
              Severity: Minor
              Found in app/models/compute_resources/foreman/model/libvirt.rb - About 5 hrs to fix

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

                    <FormGroup
                      label={__('Smart proxy')}
                      fieldId="reg_smart_proxy"
                      labelIcon={
                        <LabelIcon
                webpack/assets/javascripts/react_app/routes/RegistrationCommands/RegistrationCommandsPage/components/fields/HostGroup.js on lines 14..28

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

                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