theforeman/foreman

View on GitHub

Showing 1,266 of 1,266 total issues

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

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

  render() {
    const {
      changeDiffViewType,
      changeSetting,
      changeTab,

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

                <GridItem span={2} rowSpan={2} className="status-count text-center">
                  <div style={{ fontSize: '1.5em' }}>
                    <GlobalStatusIcon status={1} />
                  </div>
                  <LinkOrLabel
    webpack/assets/javascripts/react_app/components/HostStatuses/Status/index.js on lines 97..109
    webpack/assets/javascripts/react_app/components/HostStatuses/Status/index.js on lines 123..135

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

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

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

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

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

    Refactorings

    Further Reading

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

                <GridItem span={2} rowSpan={2} className="status-count text-center">
                  <div style={{ fontSize: '1.5em' }}>
                    <GlobalStatusIcon status={2} />
                  </div>
                  <LinkOrLabel
    webpack/assets/javascripts/react_app/components/HostStatuses/Status/index.js on lines 97..109
    webpack/assets/javascripts/react_app/components/HostStatuses/Status/index.js on lines 110..122

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

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

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

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

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

    Refactorings

    Further Reading

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

                <GridItem span={2} rowSpan={2} className="status-count text-center">
                  <div style={{ fontSize: '1.5em' }}>
                    <GlobalStatusIcon status={0} />
                  </div>
                  <LinkOrLabel
    webpack/assets/javascripts/react_app/components/HostStatuses/Status/index.js on lines 110..122
    webpack/assets/javascripts/react_app/components/HostStatuses/Status/index.js on lines 123..135

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

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

    class Role < ApplicationRecord
      audited
      include Authorizable
      include ScopedSearchExtensions
      extend FriendlyId
    Severity: Minor
    Found in app/models/role.rb - About 4 hrs to fix

      Class PuppetFactParser has 37 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

        File audits_helper.rb has 367 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module AuditsHelper
          AUDIT_ADD = 'add'
          AUDIT_REMOVE = 'remove'
        
          # lookup the Model representing the numerical id and return its label
        Severity: Minor
        Found in app/helpers/audits_helper.rb - About 4 hrs to fix

          File Layout.fixtures.js has 365 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const mockOnClick = jest.fn();
          
          const subItemsA = [
            {
              title: 'Aa',

            Method id_to_label has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

              def id_to_label(name, change, audit: @audit, truncate: true)
                return _("N/A") if change.nil?
                case name
                  when "ancestry"
                    label = change.blank? ? "" : change.split('/').map { |i| Hostgroup.find(i).name rescue _("N/A") }.join('/')
            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

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

                  error: {
                    "owned": details.filter(({ global_status: gs }) => gs == 2).map(({ owned }) => owned).reduce((a, b) => a + b),
                    "total": details.filter(({ global_status: gs }) => gs == 2).map(({ total }) => total).reduce((a, b) => a + b),
                  },
            webpack/assets/javascripts/react_app/components/HostStatuses/Status/Status.test.js on lines 33..36
            webpack/assets/javascripts/react_app/components/HostStatuses/Status/Status.test.js on lines 37..40

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 130.

            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('warning alert', () => {
                const setWarning = jest.fn();
                const component = mount(
                  <CounterInput value={11} recommendedMaxValue={10} inputKey={'cpus'} setWarning={setWarning} />
                );
            webpack/assets/javascripts/react_app/components/common/forms/CounterInput/__tests__/CounterInput.test.js on lines 16..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 130.

            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

                  ok: {
                    "owned": details.filter(({ global_status: gs }) => gs == 0).map(({ owned }) => owned).reduce((a, b) => a + b),
                    "total": details.filter(({ global_status: gs }) => gs == 0).map(({ total }) => total).reduce((a, b) => a + b),
                  },
            webpack/assets/javascripts/react_app/components/HostStatuses/Status/Status.test.js on lines 37..40
            webpack/assets/javascripts/react_app/components/HostStatuses/Status/Status.test.js on lines 41..44

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

            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

                  warn: {
                    "owned": details.filter(({ global_status: gs }) => gs == 1).map(({ owned }) => owned).reduce((a, b) => a + b),
                    "total": details.filter(({ global_status: gs }) => gs == 1).map(({ total }) => total).reduce((a, b) => a + b),
                  },
            webpack/assets/javascripts/react_app/components/HostStatuses/Status/Status.test.js on lines 33..36
            webpack/assets/javascripts/react_app/components/HostStatuses/Status/Status.test.js on lines 41..44

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

            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('error alert', async () => {
                const setError = jest.fn();
                const component = mount(
                  <CounterInput value={21} max={20} inputKey={'cpus'} setError={setError} />
                );
            webpack/assets/javascripts/react_app/components/common/forms/CounterInput/__tests__/CounterInput.test.js on lines 7..14

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

            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

                if (!(useds == null || descendants == 'useds')) {
                  var used_ids = $.parseJSON(useds);
                  $.each(used_ids, function(index,used_id){
                    opt_id = sanitize(used_id+'');
                    $(msid).find('li#'+opt_id+'-selection').addClass('used_by_hosts').tooltip({container: 'body', title: __("This is used by a host"), placement: "right"});
            Severity: Major
            Found in app/assets/javascripts/jquery.multi-select.js and 1 other location - About 4 hrs to fix
            app/assets/javascripts/jquery.multi-select.js on lines 43..49

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

            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

                if (!(inheriteds == null || inheriteds == 'undefined')) {
                  var inherited_ids = $.parseJSON(inheriteds);
                  $.each(inherited_ids, function(index,inherited_id){
                    opt_id = sanitize(inherited_id+'');
                    $(msid).find('li#'+opt_id+'-selection').addClass('inherited').tooltip({container: 'body', title: __("This is inherited from parent"), placement: "right"});
            Severity: Major
            Found in app/assets/javascripts/jquery.multi-select.js and 1 other location - About 4 hrs to fix
            app/assets/javascripts/jquery.multi-select.js on lines 36..42

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

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

            module FormHelper
              def text_f(f, attr, options = {})
                field(f, attr, options) do
                  addClass options, "form-control"
                  options[:focus_on_load] = true if options[:focus_on_load].nil? && attr.to_s == 'name'
            Severity: Minor
            Found in app/helpers/form_helper.rb - About 4 hrs to fix

              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

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

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

              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

              Severity
              Category
              Status
              Source
              Language