rubinius/rubinius

View on GitHub
core/type.rb

Summary

Maintainability
F
6 days
Test Coverage

File type.rb has 599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Rubinius
  module Type
    # Performs a direct kind_of? check on the object bypassing any method
    # overrides.
    def self.object_kind_of?(obj, cls)
Severity: Major
Found in core/type.rb - About 1 day to fix

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

        def self.constant_scope_defined?(scope, name)
          current = scope
    
          until nil.equal? current
            break if nil.equal? current.parent
    Severity: Minor
    Found in core/type.rb - About 1 day 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 const_get has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.const_get(mod, name, inherit=true, resolve=true)
          unless object_kind_of? name, Symbol
            name = StringValue(name)
            if name.index '::' and name.size > 2
              return const_lookup mod, name, inherit, resolve
    Severity: Minor
    Found in core/type.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 include_modules_from has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.include_modules_from(included_module, klass)
          insert_at = klass
          constants_changed = false
    
          mod = included_module
    Severity: Minor
    Found in core/type.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 constant_path_defined? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.constant_path_defined?(mod, name)
          current = mod
    
          begin
            break unless object_kind_of? current, ::Module
    Severity: Minor
    Found in core/type.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 const_get has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.const_get(mod, name, inherit=true, resolve=true)
          unless object_kind_of? name, Symbol
            name = StringValue(name)
            if name.index '::' and name.size > 2
              return const_lookup mod, name, inherit, resolve
    Severity: Minor
    Found in core/type.rb - About 1 hr to fix

      Method constant_scope_defined? has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.constant_scope_defined?(scope, name)
            current = scope
      
            until nil.equal? current
              break if nil.equal? current.parent
      Severity: Minor
      Found in core/type.rb - About 1 hr to fix

        Method include_modules_from has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.include_modules_from(included_module, klass)
              insert_at = klass
              constants_changed = false
        
              mod = included_module
        Severity: Minor
        Found in core/type.rb - About 1 hr to fix

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

              def self.coerce_to_utc_offset(offset)
                offset = String.try_convert(offset) || offset
          
                if offset.kind_of?(String)
                  unless offset.encoding.ascii_compatible? && offset.match(/\A(\+|-)(\d\d):(\d\d)\z/)
          Severity: Minor
          Found in core/type.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 const_exists? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.const_exists?(mod, name, inherit = true)
                name = coerce_to_constant_name name
          
                current = mod
          
          
          Severity: Minor
          Found in core/type.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

          Avoid deeply nested control flow statements.
          Open

                        return constant.constant unless undefined.equal? constant.constant
          Severity: Major
          Found in core/type.rb - About 45 mins to fix

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

                def self.module_inspect(mod)
                  sc = singleton_class_object mod
            
                  if sc
                    case sc
            Severity: Minor
            Found in core/type.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

                          return undefined if CodeLoader.loading? constant.path
            Severity: Major
            Found in core/type.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            if k == mod
                              # ok, if we're still within the directly included modules
                              # of klass, then put future things after mod, not at the
                              # beginning.
                              insert_at = k unless superclass_seen
              Severity: Major
              Found in core/type.rb - About 45 mins to fix

                Avoid too many return statements within this method.
                Open

                              return constant
                Severity: Major
                Found in core/type.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return constant
                  Severity: Major
                  Found in core/type.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                              return constant
                    Severity: Major
                    Found in core/type.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return undefined if CodeLoader.loading? constant.path
                      Severity: Major
                      Found in core/type.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                  return resolve ? mod.const_missing(name) : undefined
                        Severity: Major
                        Found in core/type.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                    return constant
                          Severity: Major
                          Found in core/type.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                          return undefined
                            Severity: Major
                            Found in core/type.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                        return constant
                              Severity: Major
                              Found in core/type.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                              return constant.call(current)
                                Severity: Major
                                Found in core/type.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return constant.constant unless undefined.equal? constant.constant
                                  Severity: Major
                                  Found in core/type.rb - About 30 mins to fix

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

                                        def self.coerce_to_binding(obj)
                                          if obj.kind_of? Binding
                                            binding = obj
                                          elsif obj.kind_of? Proc
                                            raise TypeError, 'wrong argument type Proc (expected Binding)'
                                    Severity: Minor
                                    Found in core/type.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

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

                                                constant = bucket.constant
                                    
                                                if object_kind_of? constant, Autoload
                                                  return undefined if CodeLoader.loading? constant.path
                                                  return constant.constant unless undefined.equal? constant.constant
                                    Severity: Minor
                                    Found in core/type.rb and 1 other location - About 15 mins to fix
                                    core/type.rb on lines 438..445

                                    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

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

                                              constant = bucket.constant
                                    
                                              if object_kind_of? constant, Autoload
                                                if resolve
                                                  return constant.call(current)
                                    Severity: Minor
                                    Found in core/type.rb and 1 other location - About 15 mins to fix
                                    core/type.rb on lines 346..358

                                    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

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

                                              constant = bucket.constant
                                    
                                              if object_kind_of? constant, Autoload
                                                return undefined if CodeLoader.loading? constant.path
                                                return constant.constant unless undefined.equal? constant.constant
                                    Severity: Minor
                                    Found in core/type.rb and 1 other location - About 15 mins to fix
                                    core/type.rb on lines 422..429

                                    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

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

                                              constant = bucket.constant
                                    
                                              if object_kind_of? constant, Autoload
                                                if resolve
                                                  return constant.call(current)
                                    Severity: Minor
                                    Found in core/type.rb and 1 other location - About 15 mins to fix
                                    core/type.rb on lines 370..382

                                    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