botanicus/commonjs_modules

View on GitHub

Showing 4 of 4 total issues

Method export has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def export(*args, &block)
      if block && args.empty?
        # Lazy-loaded and cached.
        # export { Task }
        exports.define_singleton_method(:default) { @default ||= yield }
Severity: Minor
Found in lib/import.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 export has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def export(*args, &block)
      if block && args.empty?
        # Lazy-loaded and cached.
        # export { Task }
        exports.define_singleton_method(:default) { @default ||= yield }
Severity: Minor
Found in lib/import.rb - About 1 hr to fix

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

      def self.resolve_path(path)
        # import('./test') and import('../test') behave like require_relative.
        if path.start_with?('.')
          # Block in <main> is to make import work within rackup. Not sure whether it doesn't break something else though.
          location = caller_locations.find { |location| location.label == "<top (required)>" || location.label == "block in <main>" }
    Severity: Minor
    Found in lib/import.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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def method_missing(method, *args, &block)
          if method.to_s.match(/=$/) && args.length == 1 && block.nil?
            object_name = method.to_s[0..-2].to_sym
            object = args.first
    
    
    Severity: Minor
    Found in lib/import.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

    Severity
    Category
    Status
    Source
    Language