theforeman/foreman_remote_execution

View on GitHub

Showing 90 of 230 total issues

Method inner_plan has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def inner_plan(job_invocation, host, template_invocation, proxy_selector, options)
        raise _('Could not use any template used in the job invocation') if template_invocation.blank?
        features = template_invocation.template.remote_execution_features.pluck(:label).uniq
        action_subject(host,
          :host_display_name => host.to_label,
Severity: Minor
Found in app/lib/actions/remote_execution/run_host_job.rb - About 1 hr to fix

    Method fill_continuous_output has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def fill_continuous_output(continuous_output)
            if input[:with_event_logging]
              continuous_output_from_template_invocation_events(continuous_output)
              return
            end
    Severity: Minor
    Found in app/lib/actions/remote_execution/run_host_job.rb - 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

    Function JobWizard has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    export const JobWizard = ({ rerunData }) => {
      const routerSearch = useSelector(selectRouterSearch);
      const [feature, setFeature] = useState(routerSearch.feature);
      const jobCategoriesResponse = useSelector(selectJobCategoriesResponse);
      const [jobTemplateID, setJobTemplateID] = useState(
    Severity: Minor
    Found in webpack/JobWizard/JobWizard.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

    Function ReviewDetails has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    const ReviewDetails = ({
      jobCategory,
      jobTemplateID,
      advancedValues,
      scheduleValue,
    Severity: Minor
    Found in webpack/JobWizard/steps/ReviewDetails/index.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

    Function CategoryAndTemplate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    export const CategoryAndTemplate = ({
      jobCategories,
      jobTemplates,
      setJobTemplate,
      selectedTemplateID,
    Severity: Minor
    Found in webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.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

    Method register has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.register(label, name, options = {})
        pending_migrations = ::Foreman::Plugin.registered_plugins[:foreman_remote_execution]&.pending_migrations
        begin
          # Let's not try to register features if rex is not registered as a plugin
          return false if pending_migrations || pending_migrations.nil?
    Severity: Minor
    Found in app/models/remote_execution_feature.rb - 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

    Function formatter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export const formatter = (input, values, setValue) => {
      const isSelectType = !!input?.options;
      const inputType = input.value_type;
      const isTextType = inputType === 'plain' || !inputType; // null defaults to plain
    
    
    Severity: Minor
    Found in webpack/JobWizard/steps/form/Formatter.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

    Function useNameSearchGQL has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const useNameSearchGQL = apiKey => {
      const org = useForemanOrganization();
      const location = useForemanLocation();
      const [search, setSearch] = useState('');
      const queries = {
    Severity: Minor
    Found in webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js - About 1 hr to fix

      Method register has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.register(label, name, options = {})
          pending_migrations = ::Foreman::Plugin.registered_plugins[:foreman_remote_execution]&.pending_migrations
          begin
            # Let's not try to register features if rex is not registered as a plugin
            return false if pending_migrations || pending_migrations.nil?
      Severity: Minor
      Found in app/models/remote_execution_feature.rb - About 1 hr to fix

        Method render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def render
            @template_input_values ||= values_from_invocation
            @template.validate_unique_inputs!
            source = Foreman::Renderer.get_source(
              template: template,
        Severity: Minor
        Found in app/models/input_template_renderer.rb - About 1 hr to fix

          Function runFeature has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const runFeature = (hostId, feature, label, hostSearch) => dispatch => {
            const url = foremanUrl(
              hostId
                ? `/job_invocations?feature=${feature}&host_ids%5B%5D=${hostId}`
                : `/job_invocations?feature=${feature}&search=${hostSearch}`
          Severity: Minor
          Found in webpack/react_app/components/FeaturesDropdown/actions.js - About 1 hr to fix

            Method verify_permissions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def verify_permissions(host, template_invocation)
                    raise _('User can not execute job on host %s') % host.name unless User.current.can?(:view_hosts, host)
                    raise _('User can not execute this job template') unless User.current.can?(:view_job_templates, template_invocation.template)
                    infra_facet = host.infrastructure_facet
                    if (infra_facet&.foreman_instance || infra_facet&.smart_proxy_id) && !User.current.can?(:execute_jobs_on_infrastructure_hosts)
            Severity: Minor
            Found in app/lib/actions/remote_execution/run_host_job.rb - About 55 mins 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

            Method remote_execution_proxies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def remote_execution_proxies(provider, authorized = true)
                  proxies = {}
                  proxies[:subnet] = []
                  proxies[:subnet] += execution_interface.subnet6.remote_execution_proxies.with_features(provider) if execution_interface&.subnet6
                  proxies[:subnet] += execution_interface.subnet.remote_execution_proxies.with_features(provider) if execution_interface&.subnet
            Severity: Minor
            Found in app/models/concerns/foreman_remote_execution/host_extensions.rb - About 55 mins 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 FeaturesDropdown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const FeaturesDropdown = ({
              hostId,
              hostSearch,
              hostResponse,
              selectedCount,
            Severity: Minor
            Found in webpack/react_app/components/FeaturesDropdown/index.js - About 55 mins 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 JobInvocationSystemStatusChart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            const JobInvocationSystemStatusChart = ({
              data,
              isAlreadyStarted,
              formattedStartDate,
            }) => {
            Severity: Minor
            Found in webpack/JobInvocationDetail/JobInvocationSystemStatusChart.js - About 45 mins 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

            Method permitted_actions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def permitted_actions(template)
                  original = super(template)
            
                  if template.is_a?(JobTemplate)
                    original.unshift(authorized_for(controller: :job_invocations, action: :create) ? link_to(_('Run'), hash_for_new_job_invocation_path(:template_id => template.id).merge(:authorizer => authorizer)) : nil) unless template.snippet

            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

            Method status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def status
                  if task.nil? || task.state == 'scheduled'
                    QUEUED
                  elsif task.state == 'stopped' && task.result == 'success'
                    OK
            Severity: Minor
            Found in app/models/host_status/execution_status.rb - About 45 mins 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

            Method cancel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def cancel
                @job_invocation = resource_base.find(params[:id])
                result = @job_invocation.cancel(params[:force])
            
                if result
            Severity: Minor
            Found in app/controllers/job_invocations_controller.rb - About 45 mins 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

            Method triggering_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def triggering_params
                  if api_params[:recurrence].present? && api_params[:scheduling].present?
                    recurring_mode_params.merge :start_at_raw => format_datetime(api_params[:scheduling][:start_at])
                  elsif api_params[:recurrence].present? && api_params[:scheduling].empty?
                    recurring_mode_params
            Severity: Minor
            Found in app/models/job_invocation_composer.rb - About 45 mins 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

            Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def initialize(template, host = nil, invocation = nil, input_values = nil, preview = false, templates_stack = [])
            Severity: Minor
            Found in app/models/input_template_renderer.rb - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language