yast/yast-bootloader

View on GitHub

Showing 69 of 81 total issues

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

    def run
      guarded_run
    rescue ::Bootloader::NoRoot
      Yast::Report.Error(
        _("YaST cannot configure the bootloader because it failed to find the root file system.")
Severity: Minor
Found in src/lib/bootloader/config_dialog.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 merge_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def merge_attributes(default, other)
      # string attributes
      [:serial_console, :timeout, :hidden_timeout, :distributor,
       :gfxmode, :theme, :default].each do |attr|
        val = other.public_send(attr)
Severity: Minor
Found in src/lib/bootloader/grub2base.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

Consider simplifying this complex logical expression.
Open

      if Arch.i386 || Arch.x86_64 || Arch.aarch64 || Arch.arm || Arch.ppc || Arch.riscv64
        ret = kernel_cmdline
        ret << " resume=#{resume}" unless resume.empty?
        ret << " #{features}" unless features.empty?
        ret << propose_cpu_mitigations
Severity: Major
Found in src/modules/BootArch.rb - About 40 mins to fix

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

          def export_grub2(res, bootloader)
            GRUB2_BOOLEAN_MAPPING.each do |key, method|
              val = bootloader.public_send(method)
              res[key] = val ? "true" : "false" unless val.nil?
            end
    Severity: Minor
    Found in src/lib/bootloader/autoyast_converter.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 import_kernel_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def import_kernel_params(data, default)
            DEFAULT_KERNEL_PARAMS_MAPPING.each do |key, method|
              val = data.global.public_send(key)
              next unless val
    
    
    Severity: Minor
    Found in src/lib/bootloader/autoyast_converter.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 correct_loader_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def correct_loader_type(type)
          return true if type == "none"
    
          # grub2 is sooo cool...
          return true if type == "grub2" && !::Bootloader::Systeminfo.efi_mandatory?
    Severity: Minor
    Found in src/modules/BootSupportCheck.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 available_locations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def available_locations
          case Yast::Arch.architecture
          when "i386", "x86_64"
            res = [:mbr]
            return res unless can_use_boot?
    Severity: Minor
    Found in src/lib/bootloader/stage1.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 export_grub2efi has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def export_grub2efi(res, bootloader)
            GRUB2EFI_BOOLEAN_MAPPING.each do |key, method|
              val = bootloader.public_send(method)
              res[key] = val ? "true" : "false" unless val.nil?
            end
    Severity: Minor
    Found in src/lib/bootloader/autoyast_converter.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 write has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def write(etc_only: false)
          # super have to called as first as grub install require some config writen in ancestor
          super
    
          device_map.write if (Yast::Arch.x86_64 || Yast::Arch.i386) && !etc_only
    Severity: Minor
    Found in src/lib/bootloader/grub2.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 ask_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def ask_user(param)
          chosen_id = param["chosen_id"]
          result = :next
          log.info "ask user called with #{chosen_id}"
    
    
    Severity: Minor
    Found in src/lib/bootloader/proposal_client.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 load_from_kernel_args has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.load_from_kernel_args(kernel_params)
          console_parameters = kernel_params.parameter("console")
          return nil unless console_parameters
    
          console_parameters = Array(console_parameters)
    Severity: Minor
    Found in src/lib/bootloader/serial_console.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 src/lib/bootloader/kexec.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return false
      Severity: Major
      Found in src/modules/Bootloader.rb - About 30 mins to fix

        Method reset_needed? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def reset_needed?(force_reset, storage_changed)
              log.info "reset_needed? force_reset: #{force_reset} storage_changed: #{storage_changed}" \
                       "auto mode: #{Yast::Mode.auto} cfg_changed #{Yast::Bootloader.proposed_cfg_changed}"
              return true if storage_changed
              return false if Yast::Mode.autoinst || Yast::Mode.autoupgrade
        Severity: Minor
        Found in src/lib/bootloader/proposal_client.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 bootloader_by_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def bootloader_by_name(name)
                # needed to be able to store settings when moving between bootloaders
                @cached_bootloaders ||= {}
                case name
                when "grub2"
        Severity: Minor
        Found in src/lib/bootloader/bootloader_factory.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 export has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def export(config)
                log.info "exporting config #{config.inspect}"
        
                bootloader_type = config.name
                res = { "loader_type" => bootloader_type }
        Severity: Minor
        Found in src/lib/bootloader/autoyast_converter.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 import_grub2efi has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def import_grub2efi(data, bootloader)
                return unless bootloader.name == "grub2-efi"
        
                GRUB2EFI_BOOLEAN_MAPPING.each do |key, method|
                  val = data.global.public_send(key)
        Severity: Minor
        Found in src/lib/bootloader/autoyast_converter.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 propose_cpu_mitigations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def propose_cpu_mitigations
              linuxrc_value = Yast::Linuxrc.value_for("mitigations")
              log.info "linuxrc mitigations #{linuxrc_value.inspect}"
              return "" unless linuxrc_value.nil? # linuxrc already has mitigations
        
        
        Severity: Minor
        Found in src/modules/BootArch.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 assign_bootloader_device has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def assign_bootloader_device(selected_location)
              log.info "assign bootloader device '#{selected_location.inspect}'"
              # first, default to all off:
              stage1.clear_devices
        
        
        Severity: Minor
        Found in src/lib/bootloader/stage1_proposal.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 write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def write
              log.info "Saving /etc/sysconfig/bootloader for #{bootloader}"
        
              write_option(:bootloader, bootloader)
        
        
        Severity: Minor
        Found in src/lib/bootloader/sysconfig.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