rubinius/rubinius

View on GitHub
core/kernel.rb

Summary

Maintainability
F
3 days
Test Coverage

File kernel.rb has 836 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Kernel
  def equal?(other)
    Rubinius.primitive :object_equal
    raise PrimitiveFailure, "Kernel#equal? primitive failed"
  end
Severity: Major
Found in core/kernel.rb - About 2 days to fix

    Method Integer has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def Integer(obj, base=nil)
        if obj.kind_of? String
          if obj.empty?
            raise ArgumentError, "invalid value for Integer: (empty string)"
          else
    Severity: Minor
    Found in core/kernel.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 Integer has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def Integer(obj, base=nil)
        if obj.kind_of? String
          if obj.empty?
            raise ArgumentError, "invalid value for Integer: (empty string)"
          else
    Severity: Minor
    Found in core/kernel.rb - About 1 hr to fix

      Method test has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def test(cmd, file1, file2=nil)
          case cmd
          when ?d
            File.directory? file1
          when ?e
      Severity: Minor
      Found in core/kernel.rb - About 1 hr to fix

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

          def eval(string, binding=nil, filename=nil, lineno=nil)
            string = StringValue(string)
            filename = StringValue(filename) if filename
            lineno = Rubinius::Type.coerce_to lineno, Fixnum, :to_i if lineno
            lineno = 1 if filename && !lineno
        Severity: Minor
        Found in core/kernel.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 singleton_methods has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def singleton_methods(all=true)
            m = Rubinius::Type.object_singleton_class self
            mt = m.method_table
            methods = mt.public_names + mt.protected_names
        
        
        Severity: Minor
        Found in core/kernel.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 at_exit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def at_exit(prc=nil, &block)
            if prc
              unless prc.respond_to?(:call)
                raise "Argument must respond to #call"
              end
        Severity: Minor
        Found in core/kernel.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 public_singleton_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def public_singleton_methods
            m = Rubinius::Type.object_singleton_class self
            methods = m.method_table.public_names
        
            while m = m.direct_superclass
        Severity: Minor
        Found in core/kernel.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

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

          def rand(limit=0)
            if limit == 0
              return Thread.current.randomizer.random_float
            end
        
        
        Severity: Minor
        Found in core/kernel.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

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

          def trace_var(name, cmd = nil, &block)
            if !cmd && !block
              raise(
                ArgumentError,
                'The 2nd argument should be a Proc/String, alternatively use a block'
        Severity: Minor
        Found in core/kernel.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

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

          def protected_singleton_methods
            m = Rubinius::Type.object_singleton_class self
            methods = m.method_table.protected_names
        
            while m = m.direct_superclass
        Severity: Minor
        Found in core/kernel.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

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

          def methods(all=true)
            methods = singleton_methods(all)
        
            if all
              # We have to special case these because unlike true, false, nil,
        Severity: Minor
        Found in core/kernel.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

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

          def open(obj, *rest, &block)
            if obj.respond_to?(:to_open)
              obj = obj.to_open(*rest)
        
              if block_given?
        Severity: Minor
        Found in core/kernel.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

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

          def String(obj)
            return obj if obj.kind_of? String
        
            unless obj.respond_to?(:to_s)
              raise TypeError, "can't convert #{obj.class} into String"
        Severity: Minor
        Found in core/kernel.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

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

          def private_singleton_methods
            sc = Rubinius::Type.object_singleton_class self
            methods = sc.method_table.private_names
        
            m = sc
        Severity: Minor
        Found in core/kernel.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

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

          def protected_singleton_methods
            m = Rubinius::Type.object_singleton_class self
            methods = m.method_table.protected_names
        
            while m = m.direct_superclass
        Severity: Minor
        Found in core/kernel.rb and 1 other location - About 35 mins to fix
        core/kernel.rb on lines 792..805

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

        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

          def public_singleton_methods
            m = Rubinius::Type.object_singleton_class self
            methods = m.method_table.public_names
        
            while m = m.direct_superclass
        Severity: Minor
        Found in core/kernel.rb and 1 other location - About 35 mins to fix
        core/kernel.rb on lines 753..766

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

        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

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

              code     = tup[0]
              line     = tup[1]
              is_block = tup[2]
              name     = tup[3]
        
        
        Severity: Minor
        Found in core/kernel.rb and 1 other location - About 20 mins to fix
        core/thread.rb on lines 416..421

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

        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

        There are no issues that match your filters.

        Category
        Status