ruby-llvm/ruby-llvm

View on GitHub

Showing 33 of 33 total issues

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

    def self.struct(elt_types, is_packed, name = nil)
      elt_types.map! { |ty| LLVM::Type(ty) }
      elt_types_ptr = FFI::MemoryPointer.new(FFI.type_size(:pointer) * elt_types.size)
      elt_types_ptr.write_array_of_pointer(elt_types)
      if name
Severity: Minor
Found in lib/llvm/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

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

  def test_const_sext
    assert i = LLVM::Int8.from_i(-1)
    assert_equal 'i8 -1', i.to_s
    assert_equal :integer, i.type.kind
    assert_equal 8, i.type.width
Severity: Minor
Found in test/integer_test.rb and 1 other location - About 50 mins to fix
test/integer_test.rb on lines 7..15

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

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 test_const_zext
    assert i = LLVM::Int8.from_i(-1)
    assert_equal 'i8 -1', i.to_s
    assert_equal :integer, i.type.kind
    assert_equal 8, i.type.width
Severity: Minor
Found in test/integer_test.rb and 1 other location - About 50 mins to fix
test/integer_test.rb on lines 18..26

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

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

Method create_machine has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_machine(triple, cpu = "", features = "",
                       opt_level = :default, reloc = :default, code_model = :default)
Severity: Minor
Found in lib/llvm/target.rb - About 45 mins to fix

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

      enum :type_kind, [
        :void, 0,
        :half, 1,
        :float, 2,
        :double, 3,
    Severity: Minor
    Found in lib/llvm/core_ffi.rb and 1 other location - About 40 mins to fix
    lib/llvm/core_ffi.rb on lines 462..480

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

    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

      enum :linkage, [
        :external, 0,
        :available_externally, 1,
        :link_once_any, 2,
        :link_once_odr, 3,
    Severity: Minor
    Found in lib/llvm/core_ffi.rb and 1 other location - About 40 mins to fix
    lib/llvm/core_ffi.rb on lines 396..414

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

    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 insert_element(vector, elem, idx, name = "")
          error = element_error(vector, idx)
    
          error ||= if !elem.is_a?(LLVM::Value)
            "elem: #{elem.inspect}"
    Severity: Minor
    Found in lib/llvm/core/builder.rb and 1 other location - About 40 mins to fix
    lib/llvm/core/builder.rb on lines 976..985

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

    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 insert_value(aggregate, elem, idx, name = "")
          error = value_error(aggregate, idx)
    
          error ||= if !elem.is_a?(LLVM::Value)
            "elem: #{elem.inspect}"
    Severity: Minor
    Found in lib/llvm/core/builder.rb and 1 other location - About 40 mins to fix
    lib/llvm/core/builder.rb on lines 921..930

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

    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

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

      def run_comparison_operation(comparison_operation, comparison_operator,
                                   operand1, operand2, return_type)
    Severity: Minor
    Found in test/comparisons_test.rb - About 35 mins to fix

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

        def different_type_assertion(operation, operand, return_type, assertion_type, expected_result)
      Severity: Minor
      Found in test/conversions_test.rb - About 35 mins to fix

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

          def integer_comparison_assertion(operation, operand1, operand2, signed, expected_result)
        Severity: Minor
        Found in test/comparisons_test.rb - About 35 mins to fix

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

              def invoke(fun, args, normal, exception, name = "")
          Severity: Minor
          Found in lib/llvm/core/builder.rb - About 35 mins to fix

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

              def integer_conversion_assertion(operation, operand, return_type, signed, expected_result)
            Severity: Minor
            Found in test/conversions_test.rb - About 35 mins to fix

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

                  def build_with_lto(pass_manager, internalize = false, run_inliner = false)
                    if pass_manager.is_a?(FunctionPassManager)
                      raise ArgumentError, "FunctionPassManager does not support LTO"
                    end
              
              
              Severity: Minor
              Found in lib/llvm/transforms/builder.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

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

                    def [](key)
                      case key
                      when String, Symbol then named(key)
                      when Integer
                        i = 0
              Severity: Minor
              Found in lib/llvm/core/module.rb and 1 other location - About 35 mins to fix
              lib/llvm/core/module.rb on lines 123..133

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

              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 [](key)
                      case key
                      when String, Symbol then named(key)
                      when Integer then
                        i = 0
              Severity: Minor
              Found in lib/llvm/core/module.rb and 1 other location - About 35 mins to fix
              lib/llvm/core/module.rb on lines 207..217

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

              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 inbounds_gep(ptr, indices, name = "")
                    indices = Array(indices)
                    FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr|
                      indices_ptr.write_array_of_pointer(indices)
                      return Instruction.from_ptr(
              Severity: Minor
              Found in lib/llvm/core/builder.rb and 1 other location - About 30 mins to fix
              lib/llvm/core/builder.rb on lines 548..553

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

              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 gep(ptr, indices, name = "")
                    indices = Array(indices)
                    FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr|
                      indices_ptr.write_array_of_pointer(indices)
                      return Instruction.from_ptr(
              Severity: Minor
              Found in lib/llvm/core/builder.rb and 1 other location - About 30 mins to fix
              lib/llvm/core/builder.rb on lines 566..571

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

              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

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

                    def each
                      return to_enum :each unless block_given?
                      inst, last = first, last
              
                      while inst
              Severity: Minor
              Found in lib/llvm/core/value.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(mod, options)
                    FFI::MemoryPointer.new(FFI.type_size(:pointer)) do |ptr|
                      error   = FFI::MemoryPointer.new(FFI.type_size(:pointer))
                      status  = create_execution_engine_for_module(ptr, mod, error, options)
                      errorp  = error.read_pointer
              Severity: Minor
              Found in lib/llvm/execution_engine.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

              Severity
              Category
              Status
              Source
              Language