rapid7/ruby_smb

View on GitHub
lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class VirtualPathname has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

          class VirtualPathname
            SEPARATOR = File::SEPARATOR
            # see: https://ruby-doc.org/stdlib-3.1.1/libdoc/pathname/rdoc/Pathname.html
            STAT_METHODS = %i[
              atime
Severity: Minor
Found in lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

                def initialize(disk, path, **kwargs)
                  @virtual_disk = disk
                  @path = path
    
                  if kwargs.fetch(:exist?, true)
    Severity: Minor
    Found in lib/ruby_smb/server/share/provider/virtual_disk/virtual_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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

                def method_missing(symbol, *args)
                  # should we forward to one of the stat methods
                  if STAT_METHODS.include?(symbol)
                    # if we have a stat object then forward it
                    return stat.send(symbol, *args) if exist?
    Severity: Minor
    Found in lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.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

    Method children has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

                def children(with_directory=true)
                  raise Errno::ENOTDIR.new("Not a directory @ dir_initialize - #{to_s}") unless directory?
    
                  @virtual_disk.each_value.select { |dent| dent.dirname == self && dent != self }.map { |dent| with_directory ? dent : dent.basename }
                end
    Severity: Minor
    Found in lib/ruby_smb/server/share/provider/virtual_disk/virtual_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