lib/tins/dslkit.rb

Summary

Maintainability
D
1 day
Test Coverage

File dslkit.rb has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'thread'
require 'sync'

require 'tins/thread_local'

Severity: Minor
Found in lib/tins/dslkit.rb - About 5 hrs to fix

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

        def dsl_accessor(name, *default, &block)
          variable = "@#{name}"
          define_method(name) do |*args|
            if args.empty?
              result =
    Severity: Minor
    Found in lib/tins/dslkit.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 dsl_reader has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def dsl_reader(name, *default, &block)
          variable = "@#{name}"
          define_method(name) do |*args|
            if args.empty?
              result =
    Severity: Minor
    Found in lib/tins/dslkit.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 with has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.with(*ids)
          opts = Hash === ids.last ? ids.pop : {}
          ids = ids.map { |id| Regexp === id ? id : id.to_s }
          klass = opts[:superclass] ? Class.new(opts[:superclass]) : Class.new
          klass.instance_eval do
    Severity: Minor
    Found in lib/tins/dslkit.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 delegate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def delegate(method_name, opts = {})
          to = opts[:to] || UNSET
          as = opts[:as] || method_name
          raise ArgumentError, "to argument wasn't defined" if to == UNSET
          to = to.to_s
    Severity: Minor
    Found in lib/tins/dslkit.rb - About 1 hr to fix

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

          def delegate(method_name, opts = {})
            to = opts[:to] || UNSET
            as = opts[:as] || method_name
            raise ArgumentError, "to argument wasn't defined" if to == UNSET
            to = to.to_s
      Severity: Minor
      Found in lib/tins/dslkit.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 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def method_missing(id, *args)
            self.dynamic_scope_name ||= :variables
            if args.empty? and scope_reverse(dynamic_scope_name) { |c| c.key?(id) and return c[id] }
              super
            elsif args.size == 1 and id.to_s =~ /(.*?)=\Z/
      Severity: Minor
      Found in lib/tins/dslkit.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 deflect_start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def deflect_start(from, id, deflector)
            @@sync.synchronize do
              Deflect.deflecting ||= DeflectorCollection.new
              Deflect.deflecting.member?(from, id) and
                raise DeflectError, "#{from}##{id} is already deflected"
      Severity: Minor
      Found in lib/tins/dslkit.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 thread_global has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def thread_global(name, default_value = nil, &default)
            is_a?(Module) or raise TypeError, "receiver has to be a Module"
      
            default_value && default and raise ArgumentError,
              "require either default_falue or default block"
      Severity: Minor
      Found in lib/tins/dslkit.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