OpenSCAP/foreman_openscap

View on GitHub

Showing 56 of 88 total issues

Function EditableInput has 113 lines of code (exceeds 25 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: Major
Found in webpack/components/EditableInput.js - About 4 hrs to fix

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

    const withLoading = Component => {
      const Subcomponent = ({
        fetchFn,
        resultPath,
        renameData,
    Severity: Major
    Found in webpack/components/withLoading.js - About 2 hrs to fix

      Method create_arf has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.create_arf(asset, proxy, params)
            arf_report = nil
            policy = Policy.find_by :id => params[:policy_id]
            return unless policy
      
      
      Severity: Minor
      Found in app/models/foreman_openscap/arf_report.rb - About 2 hrs 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

      Class ArfReport has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class ArfReport < ::Report
          include Taxonomix
          include OpenscapProxyExtensions
      
          # attr_accessible :host_id, :reported_at, :status, :metrics
      Severity: Minor
      Found in app/models/foreman_openscap/arf_report.rb - About 2 hrs to fix

        Method prepended has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.prepended(base)
              base.has_one :asset, :as => :assetable, :class_name => "::ForemanOpenscap::Asset", :dependent => :destroy
              base.has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy"
              base.has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy"
              base.has_many :arf_reports, :class_name => '::ForemanOpenscap::ArfReport', :foreign_key => :host_id
        Severity: Major
        Found in app/models/concerns/foreman_openscap/host_extensions.rb - About 2 hrs to fix

          Method process_policy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def process_policy(policy)
                reports_of_policy = ForemanOpenscap::ArfReport.unscoped
                                                              .of_policy(policy)
                                                              .order("#{ForemanOpenscap::ArfReport.table_name}.created_at DESC")
                latest = reports_of_policy.first
          Severity: Minor
          Found in lib/foreman_openscap/message_cleaner.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 upload_from_files has a Cognitive Complexity of 15 (exceeds 5 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

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

              def self.create_arf(asset, proxy, params)
                arf_report = nil
                policy = Policy.find_by :id => params[:policy_id]
                return unless policy
          
          
          Severity: Minor
          Found in app/models/foreman_openscap/arf_report.rb - About 1 hr to fix

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

              def find_multiple
                if params.key?(:host_names) || params.key?(:host_ids) || multiple_with_filter?
                  @hosts = Host.search_for(params[:search]) if multiple_with_filter?
                  @hosts ||= Host.merge(Host.where(id: params[:host_ids]).or(Host.where(name: params[:host_names])))
                  if @hosts.empty?
            Severity: Minor
            Found in app/controllers/policies_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 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 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 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

                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

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

                        Severity
                        Category
                        Status
                        Source
                        Language