stdlib/pathname.rb

Summary

Maintainability
C
1 day
Test Coverage

Method plus has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def plus(path1, path2) # -> path # :nodoc:
    prefix2 = path2
    index_list2 = []
    basename_list2 = []
    while (r2 = chop_basename(prefix2))
Severity: Minor
Found in stdlib/pathname.rb - About 3 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 relative_path_from has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def relative_path_from(base_directory)
    dest_directory = cleanpath.to_s
    base_directory = base_directory.cleanpath.to_s
    dest_prefix = dest_directory
    dest_names = []
Severity: Minor
Found in stdlib/pathname.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 plus has 38 lines of code (exceeds 30 allowed). Consider refactoring.
Open

  def plus(path1, path2) # -> path # :nodoc:
    prefix2 = path2
    index_list2 = []
    basename_list2 = []
    while (r2 = chop_basename(prefix2))
Severity: Minor
Found in stdlib/pathname.rb - About 1 hr to fix

    Method relative_path_from has 33 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

      def relative_path_from(base_directory)
        dest_directory = cleanpath.to_s
        base_directory = base_directory.cleanpath.to_s
        dest_prefix = dest_directory
        dest_names = []
    Severity: Minor
    Found in stdlib/pathname.rb - About 1 hr to fix

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

        def join(*args)
          return self if args.empty?
          result = args.pop
          result = Pathname.new(result) unless Pathname === result
          return result if result.absolute?
      Severity: Minor
      Found in stdlib/pathname.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(path)
          if Pathname === path
            @path = path.path.to_s
          elsif path.respond_to?(:to_path)
            @path = path.to_path
      Severity: Minor
      Found in stdlib/pathname.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

      There are no issues that match your filters.

      Category
      Status