OpenSCAP/foreman_openscap

View on GitHub

Showing 76 of 163 total issues

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

      def modify_items(items, oval_policy, ansible_role, roles_method)
        items.reduce(CheckCollection.new) do |memo, item|
          role_ids = item.ansible_role_ids + [ansible_role.id]
          item.ansible_role_ids = role_ids unless item.send(roles_method).include? ansible_role
          item.save if item.changed?
Severity: Minor
Found in app/services/foreman_openscap/oval/configure.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 add_overrides has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def add_overrides(collection, host_or_hg, config)
      model_match = host_or_hg.class.name.underscore =~ /\Ahostgroup\z/ ? "hostgroup" : "fqdn"
      collection.where(:override => true).find_each do |override|
        return unless host_or_hg.openscap_proxy && (url = host_or_hg.openscap_proxy.url).present?

Severity: Minor
Found in app/services/foreman_openscap/hostgroup_overrider_common.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 scap_content_profile_selector has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def scap_content_profile_selector(form)
    if profiles_selection.length == 1
      select_f form, :scap_content_profile_id, profiles_selection, :id, :title,
               { :selected => @policy.scap_content_profile_id },
               { :label => _("XCCDF Profile"),
Severity: Minor
Found in app/helpers/policies_helper.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 assign has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def assign(oval_policy, ids, model_class)
        check_collection = ::ForemanOpenscap::Oval::Setup.new.run
        return check_collection unless check_collection.all_passed?

        ansible_role = @config.find_config_item
Severity: Minor
Found in app/services/foreman_openscap/oval/configure.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 override_param has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def override_param(handler, param_name, param, config, key_type, default_value = nil)
Severity: Minor
Found in app/services/foreman_openscap/lookup_key_overrides_common.rb - About 45 mins to fix

    Method populate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def populate
          return unless @policy.deploy_by && Policy.deploy_by_variants.include?(@policy.deploy_by)
          config = @name_sevice.config_for @policy.deploy_by.to_sym
          return unless config.available?
          return unless config.managed_overrides?
    Severity: Minor
    Found in app/services/foreman_openscap/hostgroup_overrider.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

    Function ReviewHosts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const ReviewHosts = () => {
      const {
        hostId,
        setHostIdsParam,
        defaultFailedHostsSearch,
    Severity: Minor
    Found in webpack/components/OpenscapRemediationWizard/steps/ReviewHosts.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

    Function Finish has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

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

        def no_mixed_deployments
          assets.each do |asset|
            assetable = asset.assetable
            next unless assetable
            unless assetable.policies.where.not(:id => id).pluck(:deploy_by).all? { |deployed_by| deployed_by == deploy_by }
    Severity: Minor
    Found in app/models/foreman_openscap/policy.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

    Method migrate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def migrate
          ForemanOpenscap::Asset.where(:assetable_type => "Host::Base").select { |a| a.host.nil? }.map(&:destroy)
          ForemanOpenscap::Asset.where(:assetable_type => "Hostgroup").select { |a| a.hostgroup.nil? }.map(&:destroy)
    
          old_arf_reports = ActiveRecord::Migration.execute("SELECT * FROM foreman_openscap_arf_reports;")
    Severity: Minor
    Found in lib/foreman_openscap/data_migration.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 method.
    Open

            return false
    Severity: Major
    Found in app/validators/foreman_openscap/data_stream_validator.rb - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

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

        Avoid too many return statements within this method.
        Open

                return false
        Severity: Major
        Found in app/validators/foreman_openscap/data_stream_validator.rb - About 30 mins to fix

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

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

              def update_client_params(model_match, config)
                client_item = config.find_config_item self.public_send(config.all_collection_method)
                return unless client_item
                lookup_keys = client_item.public_send(config.override_method_name)
                server_key = lookup_keys.find { |param| param.key == config.server_param }
          Severity: Minor
          Found in app/models/concerns/foreman_openscap/openscap_proxy_core_extensions.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 references_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.references_links(references)
                return if references.nil?
                html_links = []
                references.each do |reference|
                  next if reference['title'] == 'test_attestation' # A blank url created by OpenSCAP
          Severity: Minor
          Found in app/models/foreman_openscap/arf_report.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