theforeman/foreman

View on GitHub

Showing 1,256 of 1,256 total issues

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

        <DescriptionListGroup>
          <DescriptionListTerm>{__('OS')}</DescriptionListTerm>
          <DescriptionListDescription>
            <SkeletonLoader
              status={status}
webpack/assets/javascripts/react_app/components/HostDetails/Tabs/Details/Cards/OperatingSystem/index.js on lines 27..45

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

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

class ComputeResource < ApplicationRecord
  audited :except => [:attrs]
  include Taxonomix
  include Encryptable
  include Authorizable
Severity: Minor
Found in app/models/compute_resource.rb - About 4 hrs to fix

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

                        <SplitItem>
                          <Label
                            isCompact
                            color="blue"
                            render={({ className, content, componentRef }) => (
    webpack/assets/javascripts/react_app/components/HostDetails/index.js on lines 173..191

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

    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

                        <SplitItem>
                          <Label
                            isCompact
                            color="blue"
                            render={({ className, content, componentRef }) => (
    webpack/assets/javascripts/react_app/components/HostDetails/index.js on lines 192..210

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

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

      def self.try_to_login(login, password, api_request = false)
        # Make sure no one can sign in with an empty password
        return nil if password.to_s.empty?
    
        # user is already in local database
    Severity: Minor
    Found in app/models/user.rb - About 4 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 get has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      get: async url => {
        if (url === '/api/v2/roles?per_page=all&search=locked=false') {
          return {
            data: {
              total: 3,

      Class PuppetFactParser has 35 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class PuppetFactParser < FactParser
        attr_reader :facts
      
        def operatingsystem
          orel = os_release.dup
      Severity: Minor
      Found in app/services/puppet_fact_parser.rb - About 4 hrs to fix

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

            intl.ready.then(() => {
              wrapper.update();
              if (process.version.startsWith('v14') || process.version.startsWith('v16')) {
                expect(wrapper.find('LongDateTime')).toMatchInlineSnapshot(
                  `
        webpack/assets/javascripts/react_app/components/common/dates/LongDateTime.test.js on lines 19..74
        webpack/assets/javascripts/react_app/components/common/dates/LongDateTime.test.js on lines 153..210

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

        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

            intl.ready.then(() => {
              wrapper.update();
              if (process.version.startsWith('v14') || process.version.startsWith('v16')) {
                expect(wrapper.find('LongDateTime')).toMatchInlineSnapshot(
                  `
        webpack/assets/javascripts/react_app/components/common/dates/LongDateTime.test.js on lines 86..145
        webpack/assets/javascripts/react_app/components/common/dates/LongDateTime.test.js on lines 153..210

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

        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

            intl.ready.then(() => {
              wrapper.update();
              if (process.version.startsWith('v14') || process.version.startsWith('v16')) {
                expect(wrapper.find('LongDateTime')).toMatchInlineSnapshot(
                  `
        webpack/assets/javascripts/react_app/components/common/dates/LongDateTime.test.js on lines 19..74
        webpack/assets/javascripts/react_app/components/common/dates/LongDateTime.test.js on lines 86..145

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

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

        require 'ipaddr'
        
        class Subnet < ApplicationRecord
          audited
          IP_FIELDS = [:network, :mask, :gateway, :dns_primary, :dns_secondary, :from, :to]
        Severity: Minor
        Found in app/models/subnet.rb - About 4 hrs to fix

          File host_edit_interfaces.js has 352 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          $(document).ready(function() {
            $('#host_name').select();
            $('#host_name').focus();
          });
          
          
          Severity: Minor
          Found in app/assets/javascripts/host_edit_interfaces.js - About 4 hrs to fix

            Method set_taxonomy has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

              def set_taxonomy
                TopbarSweeper.expire_cache
                user = User.current
                return if user.nil?
            
            
            Severity: Minor
            Found in app/controllers/concerns/application_shared.rb - About 4 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

            Class FactParser has 33 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class FactParser
              delegate :logger, :to => :Rails
              VIRTUAL = /\A([a-z0-9]+)[_|\.|:]([a-z0-9]+)\Z/
              BRIDGES = /\A(vir|lxc)?br(\d+|-[a-z0-9]+)(_nic)?\Z/
              BONDS = /\A(bond\d+)\Z|\A(lagg\d+)\Z/
            Severity: Minor
            Found in app/services/fact_parser.rb - About 4 hrs to fix

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

                      <FormGroup
                        label={__('Override?')}
                        labelIcon={
                          <Popover
                            bodyContent={
              webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.js on lines 168..202

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

              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={__('Unlimited?')}
                          labelIcon={
                            <Popover
                              bodyContent={
              webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.js on lines 121..154

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

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

                def details(audit, path = audits_path(:search => "id=#{audit.id}"))
                  if audit.action == 'update'
                    return [] unless audit.audited_changes.present?
                    audit.audited_changes.map do |name, change|
                      next if change.nil? || change.to_s.empty?
              Severity: Minor
              Found in app/helpers/audits_helper.rb - About 4 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

              Class Filter has 32 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Filter < ApplicationRecord
                audited :associated_with => :role
              
                include Taxonomix
                include Authorizable
              Severity: Minor
              Found in app/models/filter.rb - About 4 hrs to fix

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

                  it('should make notification group read', () => {
                    API.put.mockImplementation(async () => null);
                
                    const dispatch = jest.fn();
                    const dispatcher = actions.markGroupAsRead('Community');
                webpack/assets/javascripts/react_app/redux/actions/notifications/notifications.test.js on lines 65..75

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

                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 group clear', () => {
                    API.put.mockImplementation(async () => null);
                
                    const dispatch = jest.fn();
                    const dispatcher = actions.clearGroup('Community');
                webpack/assets/javascripts/react_app/redux/actions/notifications/notifications.test.js on lines 7..17

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

                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