rubinius/rubinius

View on GitHub
core/zed.rb

Summary

Maintainability
F
1 wk
Test Coverage

File zed.rb has 1402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

ARGF = Rubinius::ARGFClass.new

class Module
  def alias_method(new_name, current_name)
    new_name = Rubinius::Type.coerce_to_symbol(new_name)
Severity: Major
Found in core/zed.rb - About 3 days to fix

    Method raise has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

      def raise(exc=undefined, msg=undefined, ctx=nil, cause: nil)
        if undefined.equal? exc
          exc = $!
          exc = RuntimeError.new("No current exception") unless exc
          exc.cause = cause unless exc.cause or exc == cause
    Severity: Minor
    Found in core/zed.rb - About 5 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 open_class_under has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.open_class_under(name, sup, mod)
        unless Type.object_kind_of? mod, Module
          raise TypeError, "'#{mod.inspect}' is not a class/module"
        end
    
    
    Severity: Minor
    Found in core/zed.rb - About 4 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 open_module_under has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.open_module_under(name, mod)
        unless Type.object_kind_of? mod, Module
          raise TypeError, "'#{mod.inspect}' is not a class/module"
        end
    
    
    Severity: Minor
    Found in core/zed.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 add_defn_method has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.add_defn_method(name, executable, lexical_scope, vis)
        # TODO: puts serial on MethodTable entry
        unless Type.object_kind_of? executable, String
        executable.serial = 1
        if executable.respond_to? :scope=
    Severity: Minor
    Found in core/zed.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 method_missing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def method_missing(meth, *args)
        cls = NoMethodError
    
        case Rubinius.method_missing_reason
        when :private
    Severity: Minor
    Found in core/zed.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 alias_method has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def alias_method(new_name, current_name)
        new_name = Rubinius::Type.coerce_to_symbol(new_name)
        current_name = Rubinius::Type.coerce_to_symbol(current_name)
        mod, entry = lookup_method(current_name, true, false)
    
    
    Severity: Minor
    Found in core/zed.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 _specialize has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self._specialize(attrs)
        # Because people are crazy, they subclass Struct directly, ie.
        #  class Craptastic < Struct
        #
        # NOT
    Severity: Minor
    Found in core/zed.rb - About 1 hr to fix

      Method method_missing has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def method_missing(meth, *args)
          cls = NoMethodError
      
          case Rubinius.method_missing_reason
          when :private
      Severity: Minor
      Found in core/zed.rb - About 1 hr to fix

        Method attach_method has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.attach_method(name, executable, lexical_scope, recv)
            # TODO: puts serial on MethodTable entry
            unless Type.object_kind_of? executable, String
            executable.serial = 1
            if executable.respond_to? :scope=
        Severity: Minor
        Found in core/zed.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 raise has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def raise(exc=undefined, msg=undefined, ctx=nil, cause: nil)
            if undefined.equal? exc
              exc = $!
              exc = RuntimeError.new("No current exception") unless exc
              exc.cause = cause unless exc.cause or exc == cause
        Severity: Minor
        Found in core/zed.rb - About 1 hr to fix

          Method open_module_under has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.open_module_under(name, mod)
              unless Type.object_kind_of? mod, Module
                raise TypeError, "'#{mod.inspect}' is not a class/module"
              end
          
          
          Severity: Minor
          Found in core/zed.rb - About 1 hr to fix

            Method open_class_under has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.open_class_under(name, sup, mod)
                unless Type.object_kind_of? mod, Module
                  raise TypeError, "'#{mod.inspect}' is not a class/module"
                end
            
            
            Severity: Minor
            Found in core/zed.rb - About 1 hr to fix

              Method alias_method has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def alias_method(new_name, current_name)
                  new_name = Rubinius::Type.coerce_to_symbol(new_name)
                  current_name = Rubinius::Type.coerce_to_symbol(current_name)
                  mod, entry = lookup_method(current_name, true, false)
              
              
              Severity: Minor
              Found in core/zed.rb - About 1 hr to fix

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

                  def const_set(name, value)
                    name = Rubinius::Type.coerce_to_constant_name name
                    Rubinius.check_frozen
                
                    if Rubinius::Type.object_kind_of? value, Module
                Severity: Minor
                Found in core/zed.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def initialize(utime=nil, stime=nil, cutime=nil, cstime=nil,
                                   tutime=nil, tstime=nil)
                Severity: Minor
                Found in core/zed.rb - About 45 mins to fix

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

                        def initialize(name, flags=nil)
                          # Accept nil and check for ruby-ffi API compat
                          flags ||= RTLD_LAZY | RTLD_GLOBAL
                  
                          unless name
                  Severity: Minor
                  Found in core/zed.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 _specialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self._specialize(attrs)
                      # Because people are crazy, they subclass Struct directly, ie.
                      #  class Craptastic < Struct
                      #
                      # NOT
                  Severity: Minor
                  Found in core/zed.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 remove_method has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def remove_method(*names)
                      names.each do |name|
                        name = Rubinius::Type.coerce_to_symbol(name)
                        Rubinius.check_frozen
                  
                  
                  Severity: Minor
                  Found in core/zed.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 include(*modules)
                      modules.reverse_each do |mod|
                        if !mod.kind_of?(Module) or mod.kind_of?(Class)
                          raise TypeError, "wrong argument type #{mod.class} (expected Module)"
                        end
                  Severity: Minor
                  Found in core/zed.rb and 1 other location - About 35 mins to fix
                  core/module.rb on lines 753..767

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

                  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

                      unless Type.object_kind_of? executable, String
                      executable.serial = 1
                      if executable.respond_to? :scope=
                        # If we're adding a method inside ane eval, dup it so that
                        # we don't share the CompiledCode with the eval, since
                  Severity: Minor
                  Found in core/zed.rb and 1 other location - About 25 mins to fix
                  core/zed.rb on lines 483..494

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

                  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

                      unless Type.object_kind_of? executable, String
                      executable.serial = 1
                      if executable.respond_to? :scope=
                        # If we're adding a method inside ane eval, dup it so that
                        # we don't share the CompiledCode with the eval, since
                  Severity: Minor
                  Found in core/zed.rb and 1 other location - About 25 mins to fix
                  core/zed.rb on lines 447..458

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

                  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

                      case total
                      when Fixnum
                        if total == 0
                          @glob_cache = nil
                        else
                  Severity: Minor
                  Found in core/zed.rb and 1 other location - About 15 mins to fix
                  core/zed.rb on lines 1699..1709

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

                  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

                      case total
                      when Fixnum
                        if total == 0
                          @cache = nil
                        else
                  Severity: Minor
                  Found in core/zed.rb and 1 other location - About 15 mins to fix
                  core/zed.rb on lines 1064..1074

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

                  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