GSI-HPC/sys-chef-cookbook

View on GitHub

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    action :clear do
      install_sdparm
    
      todo = []
      load_sdparm.each do |disk, params|
    Severity: Major
    Found in providers/sdparm.rb and 1 other location - About 1 hr to fix
    providers/sdparm.rb on lines 3..19

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 67.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    action :set do
      install_sdparm
    
      todo = []
      load_sdparm.each do |disk, params|
    Severity: Major
    Found in providers/sdparm.rb and 1 other location - About 1 hr to fix
    providers/sdparm.rb on lines 23..39

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 67.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        if node['sys']['networkd']['network']
          node['sys']['networkd']['network'].each do |name, config|
            number_prefix = ''
            unless name.match(/^[0-9]{2}-/)
              number_prefix = '20-'
      Severity: Major
      Found in recipes/networkd.rb and 1 other location - About 1 hr to fix
      recipes/networkd.rb on lines 88..99

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 50.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        if node['sys']['networkd']['netdev']
          node['sys']['networkd']['netdev'].each do |name, config|
            number_prefix = ''
            unless name.match(/^[0-9]{2}-/)
              number_prefix = '10-'
      Severity: Major
      Found in recipes/networkd.rb and 1 other location - About 1 hr to fix
      recipes/networkd.rb on lines 104..115

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 50.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        action :remove do
        
          name = new_resource.name
          path = "#{base_path}/#{name}"
        
        
        Severity: Minor
        Found in providers/apt_conf.rb and 1 other location - About 45 mins to fix
        providers/apt_preference.rb on lines 48..62

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        action :remove do
        
          name = new_resource.name
          path = "#{base_path}/#{name}"
        
        
        Severity: Minor
        Found in providers/apt_preference.rb and 1 other location - About 45 mins to fix
        providers/apt_conf.rb on lines 47..61

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            if node['sys']['networkd']['netdev']
              node['sys']['networkd']['netdev'].keys.each do |name|
                number_prefix = ''
                unless name.match(/^[0-9]{2}-/)
                  number_prefix = '10-'
          Severity: Minor
          Found in recipes/networkd.rb and 2 other locations - About 35 mins to fix
          recipes/networkd.rb on lines 29..35
          recipes/networkd.rb on lines 49..55

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 36.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            if node['sys']['networkd']['network']
              node['sys']['networkd']['network'].keys.each do |name|
                number_prefix = ''
                unless name.match(/^[0-9]{2}-/)
                  number_prefix = '20-'
          Severity: Minor
          Found in recipes/networkd.rb and 2 other locations - About 35 mins to fix
          recipes/networkd.rb on lines 29..35
          recipes/networkd.rb on lines 39..45

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 36.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language