yast/yast-bootloader

View on GitHub
src/modules/Bootloader.rb

Summary

Maintainability
D
2 days
Test Coverage

File Bootloader.rb has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"
require "yast2/popup"
require "bootloader/exceptions"
require "bootloader/sysconfig"
require "bootloader/bootloader_factory"
Severity: Minor
Found in src/modules/Bootloader.rb - About 3 hrs to fix

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

        def modify_kernel_params(*args)
          ReadOrProposeIfNeeded() # ensure we have data to modify
          current_bl = ::Bootloader::BootloaderFactory.current
          # currently only grub2 bootloader supported
          return :missing unless current_bl.respond_to?(:grub_default)
    Severity: Minor
    Found in src/modules/Bootloader.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 Read has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def Read
          log.info "Reading configuration"
          # run Progress bar
          stages = [
            # progress stage, text in dialog (short, infinitiv)
    Severity: Major
    Found in src/modules/Bootloader.rb - About 2 hrs to fix

      Method modify_kernel_params has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def modify_kernel_params(*args)
            ReadOrProposeIfNeeded() # ensure we have data to modify
            current_bl = ::Bootloader::BootloaderFactory.current
            # currently only grub2 bootloader supported
            return :missing unless current_bl.respond_to?(:grub_default)
      Severity: Minor
      Found in src/modules/Bootloader.rb - About 1 hr to fix

        Method Write has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def Write
              ReadOrProposeIfNeeded()
        
              mark_as_changed
        
        
        Severity: Minor
        Found in src/modules/Bootloader.rb - About 1 hr to fix

          Method Read has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def Read
                log.info "Reading configuration"
                # run Progress bar
                stages = [
                  # progress stage, text in dialog (short, infinitiv)
          Severity: Minor
          Found in src/modules/Bootloader.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 ReadOrProposeIfNeeded has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def ReadOrProposeIfNeeded
                current_bl = ::Bootloader::BootloaderFactory.current
                return if current_bl.read? || current_bl.proposed?
          
                if Mode.config || (Stage.initial && !Mode.update)
          Severity: Minor
          Found in src/modules/Bootloader.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 Write has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def Write
                ReadOrProposeIfNeeded()
          
                mark_as_changed
          
          
          Severity: Minor
          Found in src/modules/Bootloader.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

          Avoid too many return statements within this method.
          Open

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

            There are no issues that match your filters.

            Category
            Status