Showing 48 of 48 total issues

Method go has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

    def go(s, args = ARGV, defaults: {})
      d = defaults || {}
      b, v = s.scan(/(.)(:?)/).inject([ {}, {} ]) { |t, (o, a)|
        a = a == ?:
        t[a ? 1 : 0][o] = a ? nil : false
Severity: Minor
Found in lib/tins/go.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 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 find has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

          def find(*paths)
            block_given? or return enum_for(__method__, *paths)
            paths.collect! { |d| d.dup }
            while path = paths.shift
              path = prepare_path(path)
    Severity: Minor
    Found in lib/tins/find.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 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 attempt has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def attempt(opts = {}, &block)
          sleep           = nil
          exception_class = StandardError
          prev_exception  = nil
          if Numeric === opts
    Severity: Minor
    Found in lib/tins/attempt.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 go has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def go(s, args = ARGV, defaults: {})
          d = defaults || {}
          b, v = s.scan(/(.)(:?)/).inject([ {}, {} ]) { |t, (o, a)|
            a = a == ?:
            t[a ? 1 : 0][o] = a ? nil : false
    Severity: Major
    Found in lib/tins/go.rb - About 2 hrs to fix

      Method subhash has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def subhash(*patterns)
            patterns.map! do |pat|
              pat = pat.to_sym.to_s if pat.respond_to?(:to_sym)
              pat.respond_to?(:match) ? pat : pat.to_s
            end
      Severity: Minor
      Found in lib/tins/subhash.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

      File turing.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'term/ansicolor'
      require 'tins'
      
      module Turing
        class Tape
      Severity: Minor
      Found in examples/turing.rb - About 2 hrs to fix

        Method included has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.included(modul)
              class << modul
                alias really_new new
                alias really_now now
        
        
        Severity: Major
        Found in lib/tins/time_dummy.rb - About 2 hrs to fix

          Method memoize_function has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def memoize_function(*function_ids)
                  function_ids.extend(ExtractLastArgumentOptions)
                  function_ids, opts = function_ids.extract_last_argument_options
                  mc = __memoize_cache__
                  function_ids.each do |function_id|
          Severity: Minor
          Found in lib/tins/memoize.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 description has a Cognitive Complexity of 15 (exceeds 5 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

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

                def memoize_method(*method_ids)
                  method_ids.extend(ExtractLastArgumentOptions)
                  method_ids, opts = method_ids.extract_last_argument_options
                  include CacheMethods
                  method_ids.each do |method_id|
          Severity: Minor
          Found in lib/tins/memoize.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 attempt has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def attempt(opts = {}, &block)
                sleep           = nil
                exception_class = StandardError
                prev_exception  = nil
                if Numeric === opts
          Severity: Minor
          Found in lib/tins/attempt.rb - About 1 hr to fix

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

            module Tins
              module DateTimeDummy
                def self.included(modul)
                  class << modul
                    alias really_now now
            Severity: Major
            Found in lib/tins/date_time_dummy.rb and 1 other location - About 1 hr to fix
            lib/tins/date_dummy.rb on lines 3..48

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

            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

            module Tins
              module DateDummy
                def self.included(modul)
                  class << modul
                    alias really_today today
            Severity: Major
            Found in lib/tins/date_dummy.rb and 1 other location - About 1 hr to fix
            lib/tins/date_time_dummy.rb on lines 3..47

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

            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 included has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def self.included(modul)
                  class << modul
                    alias really_today today
            
                    remove_method :today rescue nil
            Severity: Minor
            Found in lib/tins/date_dummy.rb - About 1 hr to fix

              Method included has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.included(modul)
                    class << modul
                      alias really_now now
              
                      remove_method :now rescue nil
              Severity: Minor
              Found in lib/tins/date_time_dummy.rb - About 1 hr to fix

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

                      def self.deep_const_get(path, start_module = Object)
                        path.to_s.split('::').inject(start_module) do |p, c|
                          case
                          when c.empty?
                            if start_module == Object
                Severity: Minor
                Found in lib/tins/deep_const_get.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

                Severity
                Category
                Status
                Source
                Language