rubinius/rubinius

View on GitHub
core/ffi.rb

Summary

Maintainability
D
1 day
Test Coverage

Method layout has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

      def self.layout(*spec)
        return @layout if spec.size == 0

        # Pick up a enclosing FFI::Library
        @enclosing_module ||= find_nested_parent
Severity: Minor
Found in core/ffi.rb - About 6 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 ffi.rb has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Rubinius
  module FFI

    #  Specialised error classes
    class TypeError < RuntimeError; end
Severity: Minor
Found in core/ffi.rb - About 5 hrs to fix

    Method layout has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.layout(*spec)
            return @layout if spec.size == 0
    
            # Pick up a enclosing FFI::Library
            @enclosing_module ||= find_nested_parent
    Severity: Major
    Found in core/ffi.rb - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                    type_code = @enclosing_module.find_type(f) rescue nil
      Severity: Major
      Found in core/ffi.rb - About 45 mins to fix

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

              def self.config(base, *fields)
                @size = Rubinius::Config["#{base}.sizeof"]
                cspec = Rubinius::LookupTable.new
        
                fields.each do |field|
        Severity: Minor
        Found in core/ffi.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 [] has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def [](field)
                offset, type = @cspec[field]
                raise "Unknown field #{field}" unless offset
        
                case type
        Severity: Minor
        Found in core/ffi.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

        There are no issues that match your filters.

        Category
        Status