theforeman/foreman_remote_execution

View on GitHub

Showing 230 of 230 total issues

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

  if (response.subtotal > maxResults) {
    selectOptions = [
      <SelectOption
        isDisabled
        key={0}
Severity: Major
Found in webpack/JobWizard/steps/form/ResourceSelect.js and 1 other location - About 1 hr to fix
webpack/JobWizard/steps/form/SearchSelect.js on lines 33..47

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

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 getJobInvocations has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getJobInvocations = url => async (dispatch, getState) => {
  function onGetJobInvocationsSuccess({ data }) {
    // If the job has finished, stop polling
    if (data.finished) {
      dispatch({
Severity: Minor
Found in webpack/react_app/redux/actions/jobInvocations/index.js - About 1 hr to fix

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

          <a
            className="card-pf-aggregate-status-notification"
            onClick={() => chartFilter('success')}
          >
            <span id="success_count">
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 17..25
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 27..35
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 37..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 70.

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

    export const mockApi = api => {
      api.get.mockImplementation(({ handleSuccess, ...action }) => {
        if (action.key === 'JOB_CATEGORIES') {
          handleSuccess &&
            handleSuccess({
    Severity: Minor
    Found in webpack/JobWizard/__tests__/fixtures.js - About 1 hr 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 4 locations. Consider refactoring.
    Open

          <a
            className="card-pf-aggregate-status-notification"
            onClick={() => chartFilter('cancelled')}
          >
            <span id="cancelled_count">
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 7..15
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 17..25
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 27..35

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

    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 4 locations. Consider refactoring.
    Open

          <a
            className="card-pf-aggregate-status-notification"
            onClick={() => chartFilter('failed')}
          >
            <span id="failed_count">
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 7..15
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 27..35
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 37..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 70.

    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 4 locations. Consider refactoring.
    Open

          <a
            className="card-pf-aggregate-status-notification"
            onClick={() => chartFilter('pending')}
          >
            <span id="pending_count">
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 7..15
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 17..25
    webpack/react_app/components/jobInvocations/AggregateStatus/index.js on lines 37..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 70.

    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 job_invocation_task_buttons has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def job_invocation_task_buttons(task)
        job_invocation = task.task_groups.find { |group| group.class == JobInvocationTaskGroup }.job_invocation
        task_authorizer = Authorizer.new(User.current, :collection => [task])
        buttons = []
        if (template = job_report_template) && authorized_for(controller: :report_templates, action: :generate)
    Severity: Minor
    Found in app/helpers/remote_execution_helper.rb - About 1 hr to fix

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

              <Tab
                ouiaId="finished-tab"
                eventKey={FINISHED_TAB}
                title={<TabTitleText>{__('Finished')}</TabTitleText>}
              >
      webpack/react_app/components/RecentJobsCard/RecentJobsCard.js on lines 73..79
      webpack/react_app/components/RecentJobsCard/RecentJobsCard.js on lines 80..86

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

      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

              <Tab
                ouiaId="running-tab"
                eventKey={RUNNING_TAB}
                title={<TabTitleText>{__('Running')}</TabTitleText>}
              >
      webpack/react_app/components/RecentJobsCard/RecentJobsCard.js on lines 66..72
      webpack/react_app/components/RecentJobsCard/RecentJobsCard.js on lines 80..86

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

      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

              <Tab
                ouiaId="scheduled-tab"
                eventKey={SCHEDULED_TAB}
                title={<TabTitleText>{__('Scheduled')}</TabTitleText>}
              >
      webpack/react_app/components/RecentJobsCard/RecentJobsCard.js on lines 66..72
      webpack/react_app/components/RecentJobsCard/RecentJobsCard.js on lines 73..79

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

      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 mockApi has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const mockApi = api => {
        api.get.mockImplementation(({ handleSuccess, ...action }) => {
          if (action.key === 'JOB_CATEGORIES') {
            handleSuccess &&
              handleSuccess({
      Severity: Minor
      Found in webpack/JobWizard/__tests__/fixtures.js - About 1 hr to fix

        Function getRepeatComponent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const getRepeatComponent = () => {
            switch (repeatType) {
              case repeatTypes.cronline:
                return (
                  <RepeatCron
        Severity: Minor
        Found in webpack/JobWizard/steps/Schedule/RepeatOn.js - About 1 hr to fix

          Function SearchSelect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          export const SearchSelect = ({
            name,
            selected,
            setSelected,
            placeholderText,
          Severity: Minor
          Found in webpack/JobWizard/steps/form/SearchSelect.js - About 1 hr 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 2 locations. Consider refactoring.
          Open

                      {hostMethod === hostMethods.hosts && (
                        <SelectGQL
                          selected={selectedHosts}
                          setSelected={setSelectedHosts}
                          apiKey={HOSTS}
          Severity: Major
          Found in webpack/JobWizard/steps/HostsAndInputs/index.js and 1 other location - About 1 hr to fix
          webpack/JobWizard/steps/HostsAndInputs/index.js on lines 209..218

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

          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 WIZARD_TITLES = {
            categoryAndTemplate: __('Category and template'),
            hostsAndInputs: __('Target hosts and inputs'),
            advanced: __('Advanced fields'),
            schedule: __('Schedule'),
          Severity: Major
          Found in webpack/JobWizard/JobWizardConstants.js and 1 other location - About 1 hr to fix
          webpack/JobWizard/JobWizardConstants.js on lines 14..21

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

          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 repeatTypes = {
            noRepeat: __('Does not repeat'),
            cronline: __('Cronline'),
            monthly: __('Monthly'),
            weekly: __('Weekly'),
          Severity: Major
          Found in webpack/JobWizard/JobWizardConstants.js and 1 other location - About 1 hr to fix
          webpack/JobWizard/JobWizardConstants.js on lines 29..36

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

          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

                      {hostMethod === hostMethods.hostGroups && (
                        <SelectGQL
                          selected={selectedHostGroups}
                          setSelected={setSelectedHostGroups}
                          apiKey={HOST_GROUPS}
          Severity: Major
          Found in webpack/JobWizard/steps/HostsAndInputs/index.js and 1 other location - About 1 hr to fix
          webpack/JobWizard/steps/HostsAndInputs/index.js on lines 188..197

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

          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 prepended has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.prepended(base)
                base.instance_eval do
                  has_many :targeting_hosts, :dependent => :destroy, :foreign_key => 'host_id'
                  has_many :template_invocations, :dependent => :destroy, :foreign_key => 'host_id'
                  has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id', :dependent => :destroy
          Severity: Minor
          Found in app/models/concerns/foreman_remote_execution/host_extensions.rb - About 1 hr to fix

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

            ScheduleType.propTypes = {
              isTypeStatic: PropTypes.bool.isRequired,
              scheduleType: PropTypes.string.isRequired,
              setScheduleValue: PropTypes.func.isRequired,
              setValid: PropTypes.func.isRequired,
            Severity: Major
            Found in webpack/JobWizard/steps/Schedule/ScheduleType.js and 1 other location - About 1 hr to fix
            webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js on lines 123..128

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 64.

            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