yast/yast-yast2

View on GitHub
library/types/src/modules/String.rb

Summary

Maintainability
F
5 days
Test Coverage

Method ParseOptions has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
Open

    def ParseOptions(options, parameters)
      parameters ||= {}
      ret = []

      # parsing options
Severity: Minor
Found in library/types/src/modules/String.rb - About 1 day 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

File String.rb has 461 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"

module Yast
  class StringClass < Module
    include Yast::Logger
Severity: Minor
Found in library/types/src/modules/String.rb - About 7 hrs to fix

    Class StringClass has 43 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class StringClass < Module
        include Yast::Logger
    
        # @note it is ascii chars only
        UPPER_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".freeze
    Severity: Minor
    Found in library/types/src/modules/String.rb - About 5 hrs to fix

      Method ParseOptions has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def ParseOptions(options, parameters)
            parameters ||= {}
            ret = []
      
            # parsing options
      Severity: Major
      Found in library/types/src/modules/String.rb - About 3 hrs to fix

        Method FormatFilename has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def FormatFilename(file_path, len)
              return nil unless file_path
              return file_path if len && len > file_path.size
        
              dir = file_path.split("/", -1)
        Severity: Minor
        Found in library/types/src/modules/String.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 find_longest_records has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_longest_records(items)
              return [] unless items
        
              # searching all rows
              items.each_with_object([]) do |row, result|
        Severity: Minor
        Found in library/types/src/modules/String.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 CutRegexMatch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def CutRegexMatch(input, regex, glob)
              return "" if input.nil? || input.empty?
        
              output = input
              if Builtins.regexpmatch(output, regex)
        Severity: Minor
        Found in library/types/src/modules/String.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 FormatSizeWithPrecision has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def FormatSizeWithPrecision(bytes, precision, omit_zeroes)
              return "" if bytes.nil?
        
              units = [
                # Byte abbreviated
        Severity: Minor
        Found in library/types/src/modules/String.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 deeply nested control flow statements.
        Open

                    elsif character == "\\\""
                      str << "\""
                    else
                      str << character
        Severity: Major
        Found in library/types/src/modules/String.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      elsif character == "\\\""
                        str << "\""
                      else
                        str << character
          Severity: Major
          Found in library/types/src/modules/String.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          str = CutBlanks(str) if remove_whitespace
            Severity: Major
            Found in library/types/src/modules/String.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            ret << str if !unique || !Builtins.contains(ret, str)
              Severity: Major
              Found in library/types/src/modules/String.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              str = (character == "\\\"") ? "\"" : character
                Severity: Major
                Found in library/types/src/modules/String.rb - About 45 mins to fix

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

                      def Replace(input, source, target)
                        return nil if input.nil?
                  
                        if source.nil? || source == ""
                          Builtins.y2warning("invalid parameter source: %1", source)
                  Severity: Minor
                  Found in library/types/src/modules/String.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

                  Avoid deeply nested control flow statements.
                  Open

                                ret << str if !unique || !ret.include?(str)
                  Severity: Major
                  Found in library/types/src/modules/String.rb - About 45 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status