hannesg/multi_git

View on GitHub
lib/multi_git/tree.rb

Summary

Maintainability
C
1 day
Test Coverage

Method traverse has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

      def traverse(path, options = {})
        unless path.kind_of? String
          raise ArgumentError, "Expected a String, got #{path.inspect}"
        end
        parts = path.split('/').reverse!
Severity: Minor
Found in lib/multi_git/tree.rb - About 5 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 traverse has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def traverse(path, options = {})
        unless path.kind_of? String
          raise ArgumentError, "Expected a String, got #{path.inspect}"
        end
        parts = path.split('/').reverse!
Severity: Minor
Found in lib/multi_git/tree.rb - About 1 hr to fix

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

          def glob( pattern, flags = 0 )
            return to_enum(:glob, pattern, flags) unless block_given?
            l = respond_to?(:path) ? path.size : 0
            flags |= ::File::FNM_PATHNAME
            if ::File.fnmatch(pattern, '.', flags)
    Severity: Minor
    Found in lib/multi_git/tree.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

                  if follow
                    parts.push(*entry.target.split(SLASH))
                  else
                    if parts.none?
                      return entry
    Severity: Major
    Found in lib/multi_git/tree.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    if symlinks.include? entry
                      # We have already seen this symlink
                      #TODO: it's okay to see a symlink twice if requested
                      raise MultiGit::Error::CyclicSymlink, "Cyclic symlink detected while traversing #{path} from #{self.inspect}."
                    else
      Severity: Major
      Found in lib/multi_git/tree.rb - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status