OpenSCAP/foreman_openscap

View on GitHub

Showing 76 of 163 total issues

Function withDelete has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const withDelete = Component => {
  const Subcomponent = ({
    confirmDeleteTitle,
    submitDelete,
    prepareMutation,
Severity: Minor
Found in webpack/components/withDeleteModal.js - About 1 hr to fix

    Function deleteMockFactory has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const deleteMockFactory = (first, second, errors = null) => {
      let called = false;
    
      const deleteMocks = [
        {

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

      const EditableInput = props => {
        const [editing, setEditing] = useState(false);
        const [submitting, setSubmitting] = useState(false);
        const [inputValue, setInputValue] = useState(props.value);
        const [error, setError] = useState('');
      Severity: Minor
      Found in webpack/components/EditableInput.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 CvesTable has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const CvesTable = props => {
        const columns = [
          { title: __('Ref Id') },
          { title: __('Has Errata?') },
          { title: __('Hosts Count') },
      Severity: Minor
      Found in webpack/routes/OvalPolicies/OvalPoliciesShow/CvesTable.js - About 1 hr to fix

        Function ConfirmModal has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const ConfirmModal = props => {
          const [callMutation, { loading }] = props.prepareMutation();
        
          const actions = [
            <Button
        Severity: Minor
        Found in webpack/components/ConfirmModal.js - About 1 hr to fix

          Function OvalPoliciesIndex has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const OvalPoliciesIndex = props => {
            const useFetchFn = componentProps =>
              useQuery(policiesQuery, {
                variables: useParamsToVars(componentProps.history),
              });
          Severity: Minor
          Found in webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesIndex.js - About 1 hr to fix

            Method initial_check_attrs has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def initial_check_attrs
                    override_msg = _("Could not update Ansible Variables with override: true")
            
                    [
                      {
            Severity: Minor
            Found in app/services/foreman_openscap/oval/setup.rb - About 1 hr to fix

              Function onCompleted has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const onCompleted = response => {
                  const failedChecks = response.data.createOvalPolicy.checkCollection.filter(
                    check => check.result === 'fail'
                  );
                  if (failedChecks.length === 0) {

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

                        def find_resources_before_create
                          policy_id = params[:policy_id].to_i
                
                          unless ForemanOpenscap::Policy.where(:id => policy_id).any?
                            upload_fail(_("Policy with id %s not found.") % policy_id)
                Severity: Minor
                Found in app/controllers/api/v2/compliance/arf_reports_controller.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 fieldWithHandlers has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const fieldWithHandlers = Component => {
                  const Subcomponent = ({ label, form, field, isRequired, ...rest }) => {
                    const fieldProps = wrapFieldProps(field);
                    const valid = shouldValidate(form, field.name);
                
                
                Severity: Minor
                Found in webpack/helpers/formFieldsHelper.js - About 1 hr to fix

                  Method upload_from_files has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def upload_from_files(files_array, from_scap_guide = false)
                        unless files_array.is_a? Array
                          @result.errors.push(_("Expected an array of files to upload, got: %s.") % files_array)
                          return @result
                        end
                  Severity: Minor
                  Found in lib/foreman_openscap/bulk_upload.rb - About 1 hr to fix

                    Method validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def validate(data_stream_content)
                          return unless data_stream_content.scap_file_changed?
                    
                          content_type = data_type(data_stream_content)
                    
                    
                    Severity: Minor
                    Found in app/validators/foreman_openscap/data_stream_validator.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 withLoading has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const withLoading = Component => {
                      const Subcomponent = ({
                        fetchFn,
                        resultPath,
                        renameData,
                    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 prepareOptions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const prepareOptions = fetchedResults => {
                        if (loading) {
                          return [
                            <SelectOption isDisabled key={0}>
                              {__('Loading...')}
                    Severity: Minor
                    Found in webpack/routes/OvalPolicies/OvalPoliciesNew/HostgroupSelect.js - About 1 hr to fix

                      Method find_resources_before_create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def find_resources_before_create
                                policy_id = params[:policy_id].to_i
                      
                                unless ForemanOpenscap::Policy.where(:id => policy_id).any?
                                  upload_fail(_("Policy with id %s not found.") % policy_id)
                      Severity: Minor
                      Found in app/controllers/api/v2/compliance/arf_reports_controller.rb - About 1 hr to fix

                        Method validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def validate(data_stream_content)
                              return unless data_stream_content.scap_file_changed?
                        
                              content_type = data_type(data_stream_content)
                        
                        
                        Severity: Minor
                        Found in app/validators/foreman_openscap/data_stream_validator.rb - About 1 hr to fix

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

                            def find_multiple
                              if params[:arf_report_ids].present?
                                @arf_reports = ::ForemanOpenscap::ArfReport.where(:id => params[:arf_report_ids])
                                if @arf_reports.empty?
                                  error _('No compliance reports were found.')
                          Severity: Minor
                          Found in app/controllers/arf_reports_controller.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 submit_or_cancel_policy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def submit_or_cancel_policy(form, overwrite = nil, args = {})
                              args[:cancel_path] ||= send("#{controller_name}_path")
                              content_tag(:div, :class => "clearfix") do
                                content_tag(:div, :class => "form-actions") do
                                  text    = overwrite ? overwrite : _("Submit")
                          Severity: Minor
                          Found in app/helpers/policies_helper.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 ReviewRemediation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const ReviewRemediation = () => {
                            const {
                              fixes,
                              snippet,
                              method,
                          Severity: Minor
                          Found in webpack/components/OpenscapRemediationWizard/steps/ReviewRemediation.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 onUpdateSuccess has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const onUpdateSuccess = (
                            closeEditable,
                            stopSubmitting,
                            showToast,
                            attr,
                          Severity: Minor
                          Found in webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShowHelper.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

                          Severity
                          Category
                          Status
                          Source
                          Language