GSI-HPC/sys-chef-cookbook

View on GitHub

Showing 17 of 35 total issues

Method build_nftables_rule has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def build_nftables_rule(rule_resource)
        return rule_resource.raw.strip if rule_resource.raw

        ip_family = rule_resource.family
        table = if [:pre, :post].include?(rule_resource.direction)
Severity: Minor
Found in libraries/sys_helpers_nftables.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

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

    def get_configs(type)

      config = PamUpdate::Config.new(type)
      realtype = String.new
      [:Primary, :Additional].each do |block|
Severity: Minor
Found in libraries/pamupdate_writer.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 build_nftables_rule has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def build_nftables_rule(rule_resource)
        return rule_resource.raw.strip if rule_resource.raw

        ip_family = rule_resource.family
        table = if [:pre, :post].include?(rule_resource.direction)
Severity: Minor
Found in libraries/sys_helpers_nftables.rb - About 1 hr to fix

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

        def generate_harry_config(sections, indent=1, flags={})
          if flags[:sections].nil?
            flags[:sections] = true
          end
    
    
    Severity: Minor
    Found in libraries/sys_harry.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 generate_harry_config has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def generate_harry_config(sections, indent=1, flags={})
          if flags[:sections].nil?
            flags[:sections] = true
          end
    
    
    Severity: Minor
    Found in libraries/sys_harry.rb - About 1 hr to fix

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

              def enable_fs
                if @current_resource.enabled && mount_options_unchanged?
                  Chef::Log.debug("#{@new_resource} is already enabled - nothing to do")
                  return nil
                end
      Severity: Minor
      Found in libraries/systemd_mount_provider.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 ipmi_hw_avail has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def ipmi_hw_avail
          ipmi_available = ""
          # 38: DMI type for IPMI HW (cf. man dmidecode):
          result = shell_out('dmidecode -t 38')
          if result.exitstatus == 0
      Severity: Minor
      Found in files/default/ohai_plugins/ipmi.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_config has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def create_config(type)
            output = String.new
            configs.each do |config|
              next unless config.type == type
              stacksize = config.block[:Primary].length
      Severity: Minor
      Found in libraries/pamupdate_writer.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 enabled? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def enabled?
                unless @current_resource.enabled == true
                  systemd_file = systemd_substitute(@new_resource.mount_point)
                  if ::File.exist?("/etc/systemd/system/" + systemd_file)
                    begin
      Severity: Minor
      Found in libraries/systemd_mount_provider.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 nftables_commands has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def nftables_commands(rule_resource)
              nftables_rule = ''
              commands = Array(rule_resource.command).map do |command|
                begin
                  TARGET.fetch(command.to_sym)
      Severity: Minor
      Found in libraries/sys_helpers_nftables.rb - About 1 hr to fix

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

            def parse
              fieldname = String.new
              content.each_line do |line|
                if (matches = %r{^(\S+):\s+(.*)$}.match(line))
                  fieldname = matches[1]
        Severity: Minor
        Found in libraries/pamupdate_profile.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 render_harry_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def render_harry_config(config, key, value, indent, flags)
        Severity: Minor
        Found in libraries/sys_harry.rb - About 35 mins to fix

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

                  def disable_fs
                    if @current_resource.enabled
                      systemd_file = systemd_substitute(@new_resource.mount_point)
                      if ::File.exist?("/etc/systemd/system/" + systemd_file)
                        begin
          Severity: Minor
          Found in libraries/systemd_mount_provider.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 nftables_commands has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def nftables_commands(rule_resource)
                  nftables_rule = ''
                  commands = Array(rule_resource.command).map do |command|
                    begin
                      TARGET.fetch(command.to_sym)
          Severity: Minor
          Found in libraries/sys_helpers_nftables.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 render_harry_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def render_harry_config(config, key, value, indent, flags)
                indentation = ''
                indent.times { indentation << flags[:indentation] }
                case value
                when Array
          Severity: Minor
          Found in libraries/sys_harry.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate
          
                acc = true
                fields().each_key do |k|
                  acc &&= k.instance_of?(Symbol)
          Severity: Minor
          Found in libraries/pamupdate_profile.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 port_to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def port_to_s(port)
                  if port.is_a?(String)
                    port
                  elsif port && port.is_a?(Integer)
                    port.to_s
          Severity: Minor
          Found in libraries/sys_helpers_nftables.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