ruby-llvm/ruby-llvm

View on GitHub

Showing 57 of 57 total issues

Class Builder has 106 methods (exceeds 100 allowed). Consider refactoring.
Open

  class Builder
    # Important: Call #dispose to free backend memory after use.
    def initialize
      @ptr = C.create_builder()
    end
Severity: Major
Found in lib/llvm/core/builder.rb - About 3 hrs to fix

    File value.rb has 830 lines of code (exceeds 800 allowed). Consider refactoring.
    Open

    module LLVM
      class Value
        include PointerIdentity
    
        # @private
    Severity: Major
    Found in lib/llvm/core/value.rb - About 2 hrs to fix

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

        def test_emit_x86
          assert x86 = LLVM::Target.by_name('x86')
          assert mach = x86.create_machine('x86-linux-gnu')
      
          mod = define_module('test') do |mod|
      Severity: Major
      Found in test/target_test.rb and 1 other location - About 2 hrs to fix
      test/target_test.rb on lines 132..155

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

      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_emit_x86_64
          assert x86 = LLVM::Target.by_name('x86-64')
          assert mach = x86.create_machine('x86_64-pc-linux-gnu')
      
          mod = define_module('test') do |mod|
      Severity: Major
      Found in test/target_test.rb and 1 other location - About 2 hrs to fix
      test/target_test.rb on lines 97..128

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

      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

      Class PassBuilder has 101 methods (exceeds 100 allowed). Consider refactoring.
      Open

        class PassBuilder # rubocop:disable Metrics/ClassLength
          extend FFI::Library
          ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
      
          attr_reader :passes
      Severity: Major
      Found in lib/llvm/transforms/pass_builder.rb - About 2 hrs to fix

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

          def test_frem_nan_inf
            fn = @module.functions.add("test_frem", [], LLVM.Void) do |fn|
              fn.basic_blocks.append.build do |builder|
                # frem 1 / 0 == nan
                assert inst = builder.frem(LLVM::Float.from_f(1), LLVM::Float.from_f(0))
        Severity: Major
        Found in test/instruction_test.rb and 1 other location - About 1 hr to fix
        test/instruction_test.rb on lines 251..268

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

        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_fdiv_nan_inf
            fn = @module.functions.add("test_fdiv", [], LLVM.Void) do |fn|
              fn.basic_blocks.append.build do |builder|
                # fdiv 1 / 0 == +inf
                assert inst = builder.fdiv(LLVM::Float.from_f(1), LLVM::Float.from_f(0))
        Severity: Major
        Found in test/instruction_test.rb and 1 other location - About 1 hr to fix
        test/instruction_test.rb on lines 270..287

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

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

          enum :attribute, [
            :z_ext_attribute, 1,
            :s_ext_attribute, 2,
            :no_return_attribute, 4,
            :in_reg_attribute, 8,
        Severity: Major
        Found in lib/llvm/core_ffi.rb and 1 other location - About 1 hr to fix
        lib/llvm/core.rb on lines 163..190

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

        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 :value_kind, [
              :argument, 0,
              :basic_block, 1,
              :memory_use, 2,
              :memory_def, 3,
        Severity: Major
        Found in lib/llvm/core.rb and 1 other location - About 1 hr to fix
        lib/llvm/core_ffi.rb on lines 120..147

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

        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 check_const_vector(vector)
            assert_instance_of LLVM::ConstantVector, vector
            assert_equal 2, vector.size
            assert_equal "<2 x i32> <i32 0, i32 1>", vector.to_s
        
        
        Severity: Major
        Found in test/vector_test.rb and 1 other location - About 1 hr to fix
        test/array_test.rb on lines 100..112

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

        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 check_constant_array(array)
            assert_instance_of LLVM::ConstantArray, array
            assert_equal 2, array.size
            assert_equal "[2 x i32] [i32 0, i32 1]", array.to_s
        
        
        Severity: Major
        Found in test/array_test.rb and 1 other location - About 1 hr to fix
        test/vector_test.rb on lines 117..129

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

        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_packed_constant_struct_from_struct
            struct = LLVM::ConstantStruct.const([LLVM::Int(0), LLVM::Int(1)], LLVM_PACKED)
            assert_instance_of LLVM::ConstantStruct, struct
            assert_equal 2, struct.operands.size
            assert_predicate struct.type, :aggregate?
        Severity: Minor
        Found in test/struct_test.rb and 1 other location - About 55 mins to fix
        test/struct_test.rb on lines 110..117

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

        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_unpacked_constant_struct_from_struct
            struct = LLVM::ConstantStruct.const([LLVM::Int(0), LLVM::Int(1)], LLVM_UNPACKED)
            assert_instance_of LLVM::ConstantStruct, struct
            assert_equal 2, struct.operands.size
            assert_predicate struct.type, :aggregate?
        Severity: Minor
        Found in test/struct_test.rb and 1 other location - About 55 mins to fix
        test/struct_test.rb on lines 128..135

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

        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

                  assert inst = builder.send(op, LLVM::Float.from_f(0), LLVM::Float.from_f(1))
                  assert_instance_of LLVM::Float, inst
                  assert_equal "float 0.000000e+00", inst.to_s
        
                  # 0 / 0 == nan
        Severity: Minor
        Found in test/instruction_test.rb and 1 other location - About 50 mins to fix
        test/instruction_test.rb on lines 212..218

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

        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

                  assert inst = builder.send(op, LLVM::Int32.from_i(0), LLVM::Int32.from_i(1))
                  assert_instance_of LLVM::Int32, inst
                  assert_equal "i32 0", inst.to_s
        
                  assert inst = builder.send(op, LLVM::Int32.from_i(0), LLVM::Int32.from_i(0))
        Severity: Minor
        Found in test/instruction_test.rb and 1 other location - About 50 mins to fix
        test/instruction_test.rb on lines 236..243

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

        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_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

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

              def invoke2(type, fun, args, normal, exception, name = "")
          Severity: Minor
          Found in lib/llvm/core/builder.rb - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language