theforeman/foreman_ansible

View on GitHub

Showing 33 of 105 total issues

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

/* eslint-disable max-lines */
import variableOverridesQuery from '../../../../../graphql/queries/hostVariableOverrides.gql';
import deleteAnsibleVariableOverride from '../../../../../graphql/mutations/deleteAnsibleVariableOverride.gql';
import updateAnsibleVariableOverride from '../../../../../graphql/mutations/updateAnsibleVariableOverride.gql';
import createAnsibleVariableOverride from '../../../../../graphql/mutations/createAnsibleVariableOverride.gql';

    Function NewRecurringJobModal has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const NewRecurringJobModal = props => {
      const { onClose, resourceId, resourceName } = props;
      const dispatch = useDispatch();
    
      const [callMutation] = useMutation(createJobInvocation, {

      Function withLoading has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const withLoading = Component => {
        const defaultEmptyStateProps = {
          header: __('Nothing Found!'),
          description: '',
        };
      Severity: Major
      Found in webpack/components/withLoading.js - About 3 hrs to fix

        Function ImportRolesAndVariablesTable has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        const ImportRolesAndVariablesTable = ({
          columnsData,
          rowsData,
          proxy,
          onSubmit,

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

        const DualList = props => {
          const defaultSelectState = { availableSelected: [], chosenSelected: [] };
          const [selectState, setSelectState] = useState(defaultSelectState);
        
          const onItemClick = stateName => itemName => (...args) => {
        Severity: Major
        Found in webpack/components/DualList/index.js - About 3 hrs to fix

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

            render() {
              const {
                loading,
                pagination,
                itemCount,
          Severity: Major
          Found in webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js - About 2 hrs to fix

            Function EditRolesForm has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const EditRolesForm = props => {
              const {
                assignedRoles,
                availableRoles,
                closeModal,

              File register.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              Foreman::Plugin.register :foreman_ansible do
                requires_foreman '>= 3.10.0'
                register_gettext
              
                settings do
              Severity: Minor
              Found in lib/foreman_ansible/register.rb - About 2 hrs to fix

                Function updateMockFactory has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const updateMockFactory = (variableValue, returnValue, errors = []) => {
                  const mockArray = [
                    {
                      request: {
                        query: updateAnsibleVariableOverride,

                  Function ListItem has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const ListItem = props => {
                    const draggableBtn = (
                      <div className="pf-c-dual-list-selector__draggable">
                        <button
                          className="pf-c-button pf-m-plain"
                  Severity: Minor
                  Found in webpack/components/DualList/ListItem.js - About 1 hr to fix

                    Function ansibleRoles has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const ansibleRoles = (state = initialState, action) => {
                      const { payload } = action;
                    
                      switch (action.type) {
                        case ANSIBLE_ROLES_REQUEST:

                      Function createMockFactory has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const createMockFactory = (variableValue, returnValue, errors = []) => {
                        const variables = {
                          hostId,
                          lookupKeyId: barVariableId,
                          value: variableValue,

                        Function EditableValue has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const EditableValue = props => {
                          if (!props.editing) {
                            return formatValue(props.variable);
                          }
                        
                        

                          Method import_variables_roles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def import_variables_roles(roles)
                                if roles['new']
                                  imported_roles = roles['new'].keys
                                  variables_to_import = {}
                                  remote_variables.each do |role, variables|
                          Severity: Minor
                          Found in app/services/foreman_ansible/variables_importer.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

                          Method prepare_ansible_import_rows has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def prepare_ansible_import_rows(changed, variables_importer, is_ui = true)
                                rows = []
                                changed.each do |kind, roles|
                                  imported_variables = variables_importer.import_variable_names(roles)
                                  roles.each do |role|
                          Severity: Minor
                          Found in app/helpers/foreman_ansible/ansible_roles_data_preparations.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

                          Method ansible_module_message has 36 lines of code (exceeds 25 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 1 hr to fix

                            Function pickerWithHandlers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const pickerWithHandlers = ComponentType => {
                              const Subcomponent = ({ form, field, isRequired, label, ...rest }) => {
                                const { onChange, onBlur } = wrapPickerProps(field);
                                const valid = shouldValidate(form, field.name);
                            
                            
                            Severity: Minor
                            Found in webpack/formHelper.js - About 1 hr to fix

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

                              const withLoading = Component => {
                                const defaultEmptyStateProps = {
                                  header: __('Nothing Found!'),
                                  description: '',
                                };
                              Severity: Minor
                              Found in webpack/components/withLoading.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 mockFactory has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

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

                                  def ansible_hostgroups_actions(hostgroup)
                                    actions = []
                                    is_hostgroup_empty = hostgroup.all_ansible_roles.empty? || hostgroup.hosts_count.zero?
                              
                                    if User.current.can?(:create_job_invocations)
                              Severity: Minor
                              Found in app/helpers/foreman_ansible/ansible_hostgroups_helper.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

                              Severity
                              Category
                              Status
                              Source
                              Language