theforeman/foreman

View on GitHub

Showing 1,266 of 1,266 total issues

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

  breadcrumbOptions: PropTypes.shape({
    isSwitchable: PropTypes.bool,
    resource: PropTypes.shape({
      nameField: PropTypes.string,
      resourceUrl: PropTypes.string,
webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.js on lines 115..138

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

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 Subnet has 50 methods (exceeds 20 allowed). Consider refactoring.
Open

class Subnet < ApplicationRecord
  audited
  IP_FIELDS = [:network, :mask, :gateway, :dns_primary, :dns_secondary, :from, :to]
  REQUIRED_IP_FIELDS = [:network, :mask]
  SUBNET_TYPES = {:'Subnet::Ipv4' => N_('IPv4'), :'Subnet::Ipv6' => N_('IPv6')}
Severity: Minor
Found in app/models/subnet.rb - About 7 hrs to fix

    Class Operatingsystem has 50 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Operatingsystem < ApplicationRecord
      audited
      include Authorizable
      include ValidateOsFamily
      include PxeLoaderSupport
    Severity: Minor
    Found in app/models/operatingsystem.rb - About 7 hrs to fix

      Function ColumnSelector has 170 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

          it('should dispatch request and failure actions on reject', async () => {
            const apiError = new Error('bad request');
            API.get.mockImplementation(
              () =>
                new Promise((resolve, reject) => {
        webpack/assets/javascripts/react_app/redux/API/__tests__/APIRequest.test.js on lines 55..69

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

        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 dispatch stop interval on API error', async () => {
            const apiError = new Error('bad request');
            API.get.mockImplementation(
              () =>
                new Promise((resolve, reject) => {
        webpack/assets/javascripts/react_app/redux/API/__tests__/APIRequest.test.js on lines 39..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 169.

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

        module Foreman
          module Renderer
            module Scope
              module Macros
                module Base
        Severity: Minor
        Found in app/services/foreman/renderer/scope/macros/base.rb - About 6 hrs to fix

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

                      <tr>
                        <td>
                          <a
                            className="btn clock-btn decrement-hour"
                            onClick={() => this.setTime(HOUR, -1)}
          webpack/assets/javascripts/react_app/common/hooks/Storage/index.js on lines 17..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 158.

          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

          describe('addMonths ', () => {
            const date = new Date('2/21/2019, 2:22:31 PM');
            test('same year', () => {
              const newDate = addMonths(date, 2);
              expect(newDate).toEqual(new Date('4/21/2019, 2:22:31 PM'));
          webpack/assets/javascripts/react_app/components/common/DateTimePicker/DateComponents/helpers.test.js on lines 9..23

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

          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

          describe('addDays ', () => {
            const date = new Date('2/21/2019 , 2:22:31 PM');
            test('same month', () => {
              const newDate = addDays(date, 2);
              expect(newDate).toEqual(new Date('2/23/2019 , 2:22:31 PM'));
          webpack/assets/javascripts/react_app/components/common/DateTimePicker/DateComponents/helpers.test.js on lines 25..39

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

          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 skip a notification read', () => {
              API.put.mockImplementation(async () => null);
              const state = {
                notifications: {
                  expandedGroup: 'Community',
          webpack/assets/javascripts/react_app/redux/actions/notifications/notifications.test.js on lines 19..34

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

          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 make a notification read', () => {
              API.put.mockImplementation(async () => null);
              const state = {
                notifications: {
                  expandedGroup: 'Community',
          webpack/assets/javascripts/react_app/redux/actions/notifications/notifications.test.js on lines 36..51

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

          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 Base has 44 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Base < ApplicationRecord
              audited associated_with: :host
              prepend Foreman::STI
              include Encryptable
              encrypts :password
          Severity: Minor
          Found in app/models/nic/base.rb - About 6 hrs to fix

            Class Openstack has 44 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Openstack < ComputeResource
                include KeyPairComputeResource
                attr_accessor :scheduler_hint_value
            
                delegate :flavors, :to => :client
            Severity: Minor
            Found in app/models/compute_resources/foreman/model/openstack.rb - About 6 hrs to fix

              File index.js has 416 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* eslint-disable max-lines */
              import React, { createContext, useState, useEffect } from 'react';
              import { useSelector, useDispatch, shallowEqual } from 'react-redux';
              import { Tr, Td, ActionsColumn } from '@patternfly/react-table';
              import {
              Severity: Minor
              Found in webpack/assets/javascripts/react_app/components/HostsIndex/index.js - About 6 hrs to fix

                File basic_ruby_methods.rb has 413 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module Foreman
                  module Renderer
                    module DocTemplates
                      module BasicRubyMethods
                        module Object
                Severity: Minor
                Found in app/services/foreman/renderer/doc_templates/basic_ruby_methods.rb - About 5 hrs to fix

                  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 172..196

                  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

                  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

                    Severity
                    Category
                    Status
                    Source
                    Language