rubinius/rubinius

View on GitHub
build/scripts/field_extract.rb

Summary

Maintainability
F
1 wk
Test Coverage

File field_extract.rb has 890 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class BasicPrimitive
  attr_accessor :pass_state
  attr_accessor :pass_self
  attr_accessor :pass_call_frame
  attr_accessor :pass_message
Severity: Major
Found in build/scripts/field_extract.rb - About 2 days to fix

    Method parse_stream has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_stream(f)
        class_pattern = /class\s+([^\s]+)\s*:\s*public\s+([^\s]+)/
        slot_pattern = %r!^\s*(\w+)\*?\s+\*?_(\w+)_\s*;\s*//\s*slot(.*)!
        accessor_pattern = %r!^\s*attr_(accessor|reader|writer)\((\w+),\s*(\w+)\)!
        primitive_pattern = %r%^\s*//\s+Rubinius.primitive([?!\+])?\s+:(.*)\s*$%
    Severity: Minor
    Found in build/scripts/field_extract.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 parse_stream has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parse_stream(f)
        class_pattern = /class\s+([^\s]+)\s*:\s*public\s+([^\s]+)/
        slot_pattern = %r!^\s*(\w+)\*?\s+\*?_(\w+)_\s*;\s*//\s*slot(.*)!
        accessor_pattern = %r!^\s*attr_(accessor|reader|writer)\((\w+),\s*(\w+)\)!
        primitive_pattern = %r%^\s*//\s+Rubinius.primitive([?!\+])?\s+:(.*)\s*$%
    Severity: Major
    Found in build/scripts/field_extract.rb - About 4 hrs to fix

      Method generate_invoke_stub has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def generate_invoke_stub
          return if @raw or @pass_arguments
      
          str = ""
          if arg_types.empty?
      Severity: Major
      Found in build/scripts/field_extract.rb - About 2 hrs to fix

        Class CPPClass has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class CPPClass
          def initialize(name)
            @name = name
            @super = nil
            @fields = []
        Severity: Minor
        Found in build/scripts/field_extract.rb - About 2 hrs to fix

          Method generate_invoke_stub has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def generate_invoke_stub
              return if @raw or @pass_arguments
          
              str = ""
              if arg_types.empty?
          Severity: Minor
          Found in build/scripts/field_extract.rb - About 1 hr to fix

            Method generate_glue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def generate_glue
                str = ""
                output_header str
            
                str << "  #{@type}* recv = try_as<#{@type}>(args.recv());\n"
            Severity: Minor
            Found in build/scripts/field_extract.rb - About 1 hr to fix

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

                def generate_glue
                  str = ""
                  if @raw
                    arg_count = nil
                  else
              Severity: Minor
              Found in build/scripts/field_extract.rb - About 1 hr to fix

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

                  def add_primitive(name, cpp_name, ret, args, overload=false)
                    prim = CPPPrimitive.new(name, @name)
                    prim.cpp_name = cpp_name
                    prim.return_type = ret
                    prim.arg_types = args
                Severity: Minor
                Found in build/scripts/field_extract.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 generate_accessors has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def generate_accessors
                    str = ""
                    all_fields.each do |name, type, idx, flags|
                      str << "Object* Primitives::access_#{@name}_#{name}(STATE, Executable* exec, Module* mod,
                                   Arguments& args) {\n"
                Severity: Minor
                Found in build/scripts/field_extract.rb - About 1 hr to fix

                  Method generate_invoke_stub has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def generate_invoke_stub
                      return if @raw or @pass_arguments
                  
                      str = ""
                      if arg_types.empty?
                  Severity: Minor
                  Found in build/scripts/field_extract.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 output_args has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def output_args(str, arg_types)
                      unless @pass_arguments
                        str << "  if(unlikely(args.total() != #{arg_types.size}))\n"
                        str << "    goto fail;\n\n"
                      end
                  Severity: Minor
                  Found in build/scripts/field_extract.rb - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                              if args.first == "STATE"
                                args.shift and pass_state = true
                    
                                # If the second argument is +Object* self+, we will automatically pass
                                # in the receiver of the primitive message in +output_call+
                    Severity: Major
                    Found in build/scripts/field_extract.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                if m[1]
                                  if overload
                                    raise "Unable to overload static primitives."
                                  end
                                  obj = cpp.add_static_primitive prim, m[3], @type_map[m[2]], arg_types
                      Severity: Major
                      Found in build/scripts/field_extract.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  if raw then
                                    arg_types = []
                                  else
                                    arg_types = args.map do |a|
                                      case a
                        Severity: Major
                        Found in build/scripts/field_extract.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    unless m
                                      raise "Unable to parse: '#{prototype}'"
                                    end
                          Severity: Major
                          Found in build/scripts/field_extract.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if i = args.index("Arguments& args")
                                        pass_arguments = true
                                        args[i] = :arguments
                                      end
                            Severity: Major
                            Found in build/scripts/field_extract.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                      elsif object_size_pattern.match(l)
                                        cpp.class_has_object_size
                              Severity: Major
                              Found in build/scripts/field_extract.rb - About 45 mins to fix

                                Method add_primitive has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                  def add_primitive(name, cpp_name, ret, args, overload=false)
                                Severity: Minor
                                Found in build/scripts/field_extract.rb - About 35 mins to fix

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

                                    def output_args(str, arg_types)
                                      unless @pass_arguments
                                        str << "  if(unlikely(args.total() != #{arg_types.size}))\n"
                                        str << "    goto fail;\n\n"
                                      end
                                  Severity: Minor
                                  Found in build/scripts/field_extract.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 invoke_primitives has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    def invoke_primitives
                                      write_if_new "machine/invoke_primitives.hpp" do |f|
                                        @primitives.each do |n, p|
                                          if p.respond_to? :generate_invoke_stub
                                            code = p.generate_invoke_stub
                                  Severity: Minor
                                  Found in build/scripts/field_extract.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 generate_invoke_stub has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    def generate_invoke_stub
                                      return if @raw or @pass_arguments
                                  
                                      str = ""
                                      if arg_types.empty?
                                  Severity: Minor
                                  Found in build/scripts/field_extract.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

                                  Avoid too many return statements within this method.
                                  Open

                                        return "(#{what}->reference_p() && #{what}->type_id() == #{@name}Type)"
                                  Severity: Major
                                  Found in build/scripts/field_extract.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                          return "#{what}->nil_p()"
                                    Severity: Major
                                    Found in build/scripts/field_extract.rb - About 30 mins to fix

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

                                        def generate_glue
                                          str = ""
                                          if @raw
                                            arg_count = nil
                                          else
                                      Severity: Minor
                                      Found in build/scripts/field_extract.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 generate_mark
                                          marks = generate_marks(self).rstrip
                                      
                                          str = ''
                                      
                                      
                                      Severity: Minor
                                      Found in build/scripts/field_extract.rb and 1 other location - About 20 mins to fix
                                      build/scripts/field_extract.rb on lines 584..602

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

                                      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 generate_visit
                                          visits = generate_visits(self).rstrip
                                      
                                          str = ''
                                      
                                      
                                      Severity: Minor
                                      Found in build/scripts/field_extract.rb and 1 other location - About 20 mins to fix
                                      build/scripts/field_extract.rb on lines 567..581

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

                                      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