taichi-ishitani/rggen

View on GitHub

Showing 40 of 40 total issues

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

      def create_new_entry(associated_category, body)
        ComponentEntry.new.tap do |new_entry|
          new_entry.instance_exec(&body)
          @builder.categories.each do |name, category|
            next if associated_category && name != associated_category
Severity: Minor
Found in lib/rggen/builder/component_store.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

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

      def check_byte_size
        return if required_byte_size == :any_size
        return if register.byte_size == required_byte_size_value
        error "byte size(#{register.byte_size}) is not matched with " \
              "required size(#{required_byte_size_value})"
Severity: Minor
Found in lib/rggen/builtins/register/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

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

      def enable_item_entries(entry_name_or_names)
        Array(entry_name_or_names).each do |entry_name|
          next if @enabled_entries.include?(entry_name)
          next unless @simple_item_entries.key?(entry_name) ||
                      @list_item_entries.key?(entry_name)
Severity: Minor
Found in lib/rggen/builder/item_store.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

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

      def field_method(field_name, options, body, args, block)
Severity: Minor
Found in lib/rggen/input_base/item.rb - About 35 mins to fix

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

        def parse_initial_value(cell)
          return if empty?(cell)
          Integer(cell)
        rescue
          error "invalid value for initial value: #{cell.inspect}"
    Severity: Minor
    Found in lib/rggen/builtins/bit_field/initial_value.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 merge_code_block has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def merge_code_block(other_block)
            other_block.lines.each_with_index do |line, i|
              line.indent += @indent
              if i.zero?
                @lines.last.indent  = line.indent if last_line_empty?
    Severity: Minor
    Found in lib/rggen/core_components/code_utility/code_block.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 enable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def enable(item_or_items)
            Array(item_or_items).each do |item|
              next unless @items.key?(item)
              next if @enabled_items.include?(item)
              @enabled_items << item
    Severity: Minor
    Found in lib/rggen/builder/list_item_entry.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

      module RTL
        output_component_store :rtl do
          entry do
            component_class   OutputBase::Component
            component_factory OutputBase::ComponentFactory
    Severity: Minor
    Found in lib/rggen/core_components/rtl/setup.rb and 1 other location - About 30 mins to fix
    lib/rggen/core_components/ral/setup.rb on lines 2..16

    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

      module RAL
        output_component_store :ral do
          entry do
            component_class   OutputBase::Component
            component_factory OutputBase::ComponentFactory
    Severity: Minor
    Found in lib/rggen/core_components/ral/setup.rb and 1 other location - About 30 mins to fix
    lib/rggen/core_components/rtl/setup.rb on lines 2..16

    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

    Avoid too many return statements within this method.
    Open

            parameter? && (return true)
    Severity: Major
    Found in lib/rggen/core_components/verilog_utility/variable.rb - About 30 mins to fix

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

            def [](array_index_or_msb, lsb = array_index_or_msb)
              if array_index_or_msb.nil?
                self
              else
                new_name  =
      Severity: Minor
      Found in lib/rggen/core_components/verilog_utility/identifier.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 model_creation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def model_creation(code)
            foreach_header(code) if array?
            code << subroutine_call('`rggen_ral_create_reg_model', arguments) << nl
            foreach_footer(code) if array?
          end
      Severity: Minor
      Found in lib/rggen/builtins/register/reg_model.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 address_code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def address_code(address)
              base  = hex(address, local_address_width)
              if register.array? && register.multiple?
                increment_value = hex(byte_width, local_address_width)
                "#{base} + #{increment_value} * #{local_index}"
      Severity: Minor
      Found in lib/rggen/builtins/register/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

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

          def check_start_end_adderss_relation(cell)
            return if start_address < end_address
            return if [configuration.byte_width, byte_size].all? { |v| v == 1 }
            error "start address is equal to or greater than end address: #{cell}"
          end
      Severity: Minor
      Found in lib/rggen/builtins/register/offset_address.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

        ral do
          generate_code :reg_model_item do
            function_definition :create_fields do |f|
              f.return_type :void
              f.body { |code| body_code(code) }
      Severity: Minor
      Found in lib/rggen/builtins/register/field_model_creator.rb and 1 other location - About 25 mins to fix
      lib/rggen/builtins/register_block/sub_model_creator.rb on lines 2..11

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

      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

        ral do
          generate_code :block_model_item do
            function_definition :create_sub_models do |f|
              f.return_type :void
              f.body { |code| function_body(code) }
      Severity: Minor
      Found in lib/rggen/builtins/register_block/sub_model_creator.rb and 1 other location - About 25 mins to fix
      lib/rggen/builtins/register/field_model_creator.rb on lines 2..11

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

      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 convert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def convert(cell)
              [:default, *@target_items.keys].find_yield do |t|
                case cell
                when /\A#{t}(?::(.+))?\Z/im
                  cell_value.new(t, Regexp.last_match.captures[0])
      Severity: Minor
      Found in lib/rggen/builtins/register/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

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

          def rights
            return string(:RO) if register.read_only?
            return string(:WO) if register.write_only?
            string(:RW)
          end
      Severity: Minor
      Found in lib/rggen/builtins/register/reg_model.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 def_single_delegator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def def_single_delegator(accessor, method, ali = method)
            accessor = accessor.to_s
            if method_defined?(accessor) || private_method_defined?(accessor)
              accessor = "#{accessor}()"
            end if self.class === Module
      Severity: Minor
      Found in lib/rggen/core_extensions/forwardable.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 cell_blocks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def cell_blocks(sheet)
              drop_row_size     = active_item_factories.size + 2
              drop_column_size  = 1
              sheet.rows.drop(drop_row_size).each_with_object([]) do |row, blocks|
                valid_cells = row.drop(drop_column_size)
      Severity: Minor
      Found in lib/rggen/core_components/register_map/register_block_factory.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