rubinius/rubinius

View on GitHub
core/dir_glob.rb

Summary

Maintainability
F
4 days
Test Coverage

Method compile has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

    def self.compile(pattern, flags=0, patterns=[])
      escape = (flags & File::FNM_NOESCAPE) == 0

      rbrace = nil
      lbrace = nil
Severity: Minor
Found in core/dir_glob.rb - About 7 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

File dir_glob.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Dir
  module Glob
    class Node
      def initialize(nxt, flags)
        @flags = flags
Severity: Minor
Found in core/dir_glob.rb - About 4 hrs to fix

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

        def self.glob(pattern, flags, matches=[])
          # Rubygems uses Dir[] as a glorified File.exist?  to check for multiple
          # extensions. So we went ahead and sped up that specific case.
    
          if flags == 0 and
    Severity: Minor
    Found in core/dir_glob.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 call has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

          def call(env, start)
            raise "invalid usage" if start
    
            # Even though the recursive entry is zero width
            # in this case, its left separator is still the
    Severity: Minor
    Found in core/dir_glob.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 single_compile has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.single_compile(glob, flags=0)
          parts = path_split(glob)
    
          if glob.getbyte(-1) == 47 # ?/
            last = DirectoriesOnly.new nil, flags
    Severity: Minor
    Found in core/dir_glob.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 call has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def call(env, start)
            return if !start || !File.exist?(start)
    
            # Even though the recursive entry is zero width
            # in this case, its left separator is still the
    Severity: Minor
    Found in core/dir_glob.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 compile has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.compile(pattern, flags=0, patterns=[])
          escape = (flags & File::FNM_NOESCAPE) == 0
    
          rbrace = nil
          lbrace = nil
    Severity: Major
    Found in core/dir_glob.rb - About 2 hrs to fix

      Method glob has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.glob(pattern, flags, matches=[])
            # Rubygems uses Dir[] as a glorified File.exist?  to check for multiple
            # extensions. So we went ahead and sped up that specific case.
      
            if flags == 0 and
      Severity: Minor
      Found in core/dir_glob.rb - About 1 hr to fix

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

            def self.single_compile(glob, flags=0)
              parts = path_split(glob)
        
              if glob.getbyte(-1) == 47 # ?/
                last = DirectoriesOnly.new nil, flags
        Severity: Minor
        Found in core/dir_glob.rb - About 1 hr to fix

          Method call has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def call(env, start)
                  raise "invalid usage" if start
          
                  # Even though the recursive entry is zero width
                  # in this case, its left separator is still the
          Severity: Minor
          Found in core/dir_glob.rb - About 1 hr to fix

            Method call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(env, path)
                    return if path and !File.exist?("#{path}/.")
            
                    dir = Dir.new(path ? path : ".")
                    while ent = dir.read
            Severity: Minor
            Found in core/dir_glob.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(env, path)
                    return if path and !File.exist?("#{path}/.")
            
                    begin
                      dir = Dir.new(path ? path : ".")
            Severity: Minor
            Found in core/dir_glob.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

                          break if pos == rbrace
            Severity: Major
            Found in core/dir_glob.rb - About 45 mins to fix

              Method path_split has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.path_split(str)
                    start = 0
                    ret = []
              
                    last_match = nil
              Severity: Minor
              Found in core/dir_glob.rb - About 35 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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                    if i
                      nest = 0
              
                      while i < pattern.size
                        char = pattern[i]
              Severity: Major
              Found in core/dir_glob.rb and 1 other location - About 1 hr to fix
              core/file.rb on lines 546..571

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 60.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                        while pos < rbrace and not (pattern[pos] == "," and nest == 0)
                          nest += 1 if pattern[pos] == "{"
                          nest -= 1 if pattern[pos] == "}"
              
                          if pattern[pos] == "\\" and escape
              Severity: Major
              Found in core/dir_glob.rb and 1 other location - About 1 hr to fix
              core/file.rb on lines 586..596

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 58.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status