yast/yast-yast2

View on GitHub
library/general/src/modules/AsciiFile.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    def ReadFile(file, pathname)
      Builtins.y2milestone("path=%1", pathname)
      lines = []
      if Ops.greater_than(SCR.Read(path(".target.size"), pathname), 0)
        value = Convert.to_string(SCR.Read(path(".target.string"), pathname))
Severity: Minor
Found in library/general/src/modules/AsciiFile.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 ReadFile has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def ReadFile(file, pathname)
      Builtins.y2milestone("path=%1", pathname)
      lines = []
      if Ops.greater_than(SCR.Read(path(".target.size"), pathname), 0)
        value = Convert.to_string(SCR.Read(path(".target.string"), pathname))
Severity: Major
Found in library/general/src/modules/AsciiFile.rb - About 2 hrs to fix

    File AsciiFile.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "yast"
    
    module Yast
      # Assume this /etc/fstab file
      #
    Severity: Minor
    Found in library/general/src/modules/AsciiFile.rb - About 2 hrs to fix

      Method AssertLineValid has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def AssertLineValid(file, line)
            if Builtins.haskey(Ops.get_map(file.value, "l", {}), line) &&
                Ops.get_boolean(file.value, ["l", line, "buildline"], false)
              delim = Builtins.substring(
                Ops.get_string(file.value, "delim", " "),
      Severity: Minor
      Found in library/general/src/modules/AsciiFile.rb - About 1 hr to fix

        Method ChangeLineField has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def ChangeLineField(file, line, field, entry)
              Builtins.y2debug("line %1 field %2 entry %3", line, field, entry)
              changed = false
              if !Builtins.haskey(Ops.get_map(file.value, "l", {}), line)
                Ops.set(file.value, ["l", line], {})
        Severity: Minor
        Found in library/general/src/modules/AsciiFile.rb - About 1 hr to fix

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

              def ChangeLineField(file, line, field, entry)
                Builtins.y2debug("line %1 field %2 entry %3", line, field, entry)
                changed = false
                if !Builtins.haskey(Ops.get_map(file.value, "l", {}), line)
                  Ops.set(file.value, ["l", line], {})
          Severity: Minor
          Found in library/general/src/modules/AsciiFile.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 AssertLineValid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def AssertLineValid(file, line)
                if Builtins.haskey(Ops.get_map(file.value, "l", {}), line) &&
                    Ops.get_boolean(file.value, ["l", line, "buildline"], false)
                  delim = Builtins.substring(
                    Ops.get_string(file.value, "delim", " "),
          Severity: Minor
          Found in library/general/src/modules/AsciiFile.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

          There are no issues that match your filters.

          Category
          Status