Showing 48 of 48 total issues

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

    def description(style: :namespace)
      valid_styles = %i[ namespace name parameters ]
      valid_styles.include?(style) or
        raise ArgumentError,
        "style has to be one of #{valid_styles * ', '}"
Severity: Minor
Found in lib/tins/method_description.rb - About 1 hr to fix

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

        def temp_io(content: nil, name: __method__)
          content.nil? and raise ArgumentError, "missing keyword: content"
          name = File.basename(name.to_s)
          Dir.mktmpdir do |dir|
            name = File.join(dir, name)
    Severity: Minor
    Found in lib/tins/temp_io.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 annotate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def annotate(name)
        singleton_class.class_eval do
          define_method(name) do |annotation = :annotated|
            instance_variable_set "@__annotation_#{name}__", annotation
          end
    Severity: Minor
    Found in lib/tins/annotate.rb - About 1 hr to fix

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

          class Right < State
            def initialize(opts = {})
              @goto = opts[:goto]
            end
      
      
      Severity: Major
      Found in examples/turing.rb and 1 other location - About 1 hr to fix
      examples/turing.rb on lines 91..108

      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 51.

      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

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

          class Left < State
            def initialize(opts = {})
              @goto = opts[:goto]
            end
      
      
      Severity: Major
      Found in examples/turing.rb and 1 other location - About 1 hr to fix
      examples/turing.rb on lines 112..129

      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 51.

      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

      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 format has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def format(template = '%S%d+%h:%m:%s.%f', precision: nil)
              result = template.gsub(/%[DdhmSs]/) { |directive|
                case directive
                when '%S' then ?- if negative?
                when '%d' then @days
        Severity: Minor
        Found in lib/tins/duration.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 minimize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def minimize
              result = []
              last_index = size - 1
              size.times do |i|
                result << [ self[0] ] if i == 0
        Severity: Minor
        Found in lib/tins/minimize.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 value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def value
            now = Time.now
            if stored = stored_value
              if (now - @ttl).to_i >= stored.timestamp
                Thread.new {
        Severity: Minor
        Found in lib/tins/timed_cache.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

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

            def full?(dispatch = nil, *args)
              if blank?
                obj = nil
              #elsif Module === dispatch # TODO
              #  dispatch.found?(self)
        Severity: Minor
        Found in lib/tins/xt/full.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 b[o]
                      b[o] += 1
                    else
                      b[o] = 1
                    end
        Severity: Major
        Found in lib/tins/go.rb - About 45 mins to fix

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

              def append_features(base)
                if base.instance_variable_defined?("@_dependencies")
                  base.instance_variable_get("@_dependencies") << self
                  false
                else
          Severity: Minor
          Found in lib/tins/concern.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

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

              def interpret_sleep(sleep, attempts)
                case sleep
                when nil
                when Numeric
                  if sleep < 0
          Severity: Minor
          Found in lib/tins/attempt.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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse
                reset
                until eos? || @unit_parser.eos?
                  case
                  when scan(/%f/)
          Severity: Minor
          Found in lib/tins/unit.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 implement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def implement(method_name, msg = :default)
                method_name.nil? and return
                case msg
                when ::Symbol
                  msg = MESSAGES.fetch(msg)
          Severity: Minor
          Found in lib/tins/implement.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(chunk_size: 2 ** 16, filename: nil, &content_proc)
                  content_proc or raise ArgumentError, 'need a content proc as block argument'
                  super() do |y|
                    temp_io(name: 'some-stream', content: content_proc) do |file|
                      until file.eof?
          Severity: Minor
          Found in lib/tins/temp_io_enum.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 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 annotate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def annotate(name)
              singleton_class.class_eval do
                define_method(name) do |annotation = :annotated|
                  instance_variable_set "@__annotation_#{name}__", annotation
                end
          Severity: Minor
          Found in lib/tins/annotate.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

          Severity
          Category
          Status
          Source
          Language