theforeman/foreman_ansible

View on GitHub

Showing 33 of 105 total issues

Function AnsibleRoleInputs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AnsibleRoleInputs = props => {
  const { role, idx, resourceName } = props;

  const fieldName = attr =>
    `${resourceName}[${resourceName}_ansible_roles_attributes][${idx}][${attr}]`;

    Function AnsibleRole has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const AnsibleRole = ({ role, icon, onClick, resourceName, index }) => {
      const text =
        resourceName === 'hostgroup'
          ? __('This Ansible role is inherited from parent host group')
          : __('This Ansible role is inherited from host group');
    Severity: Minor
    Found in webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.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 onCompleted has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export const onCompleted = (
      dataPath,
      onValidationError,
      toggleWorking,
      onSubmitSuccess

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

    export const advancedMockFactory = query => (
      variables,
      data,
      { errors = [], currentUser = null, refetchData = null } = {}
    ) => {
    Severity: Minor
    Found in webpack/testHelper.js - About 35 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 import_playbooks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_playbooks(playbooks_names)
          playbooks = playbooks(playbooks_names)
          result = { created: {}, updated: {} }
          playbooks.each do |playbook|
            parsed_playbook = parse_playbook playbook
    Severity: Minor
    Found in app/services/foreman_ansible/playbooks_importer.rb - About 35 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

    Avoid too many return statements within this function.
    Open

        return wrapper(<Component {...rest} {...renamedData} />);
    Severity: Major
    Found in webpack/components/withLoading.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return 'custom';
      Severity: Major
      Found in webpack/components/AnsibleHostDetail/components/JobsTab/JobsTabHelper.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return emptyWrapper(
                <EmptyState
                  {...{
                    ...defaultEmptyStateProps,
                    ...allowPrimaryAction(
        Severity: Major
        Found in webpack/components/withLoading.js - About 30 mins to fix

          Function EditableAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          const EditableAction = ({
            onValidationError,
            toggleWorking,
            onSubmitSuccess,
            open,

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

              def ansible_module_message(log)
                msg_json = parsed_message_json(log)
                return _("Execution error: #{msg_json['msg']}") if msg_json['failed'].present?
                return msg_json['censored'] if msg_json['censored'].present?
          
          
          Severity: Minor
          Found in app/helpers/foreman_ansible/ansible_reports_helper.rb - About 25 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 ansibleRoles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          const ansibleRoles = (state = initialState, action) => {
            const { payload } = action;
          
            switch (action.type) {
              case ANSIBLE_ROLES_REQUEST:
          Severity: Minor
          Found in webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js - About 25 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 import_variables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def import_variables(role_variables, new_roles)
                detect_changes(role_variables.map do |role_name, variables|
                  next if variables.blank?
                  role = import_new_role(role_name, new_roles)
                  next if role.blank?
          Severity: Minor
          Found in app/services/foreman_ansible/variables_importer.rb - About 25 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 partial_hostname_match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def partial_hostname_match(hostname)
                  return @host unless @host.new_record?
                  hosts = Host.where(Host.arel_table[:name].matches("#{hostname}.%"))
                  if hosts.count > 1
                    msg = "More than 1 host found for name #{hostname}, "
          Severity: Minor
          Found in app/services/foreman_ansible/ansible_report_importer.rb - About 25 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

          Severity
          Category
          Status
          Source
          Language