dmendel/bindata

View on GitHub

Showing 30 of 41 total issues

File dsl.rb has 379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module BinData
  # Extracts args for Records and Buffers.
  #
  # Foo.new(bar: "baz) is ambiguous as to whether :bar is a value or parameter.
  #
Severity: Minor
Found in lib/bindata/dsl.rb - About 5 hrs to fix

    Class Array has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Array < BinData::Base
        extend DSLMixin
        include Enumerable
    
        dsl_parser    :array
    Severity: Minor
    Found in lib/bindata/array.rb - About 4 hrs to fix

      Class Struct has 34 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Struct < BinData::Base
          arg_processor :struct
      
          mandatory_parameter :fields
          optional_parameters :endian, :search_prefix, :hide
      Severity: Minor
      Found in lib/bindata/struct.rb - About 4 hrs to fix

        Class Base has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Base
            extend AcceptedParametersPlugin
            include Framework
            include RegisterNamePlugin
        
        
        Severity: Minor
        Found in lib/bindata/base.rb - About 4 hrs to fix

          File io.rb has 327 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'stringio'
          
          module BinData
            # A wrapper around an IO object.  The wrapper provides a consistent
            # interface for BinData objects to use when accessing the IO.
          Severity: Minor
          Found in lib/bindata/io.rb - About 3 hrs to fix

            Class BasePrimitive has 31 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class BasePrimitive < BinData::Base
                unregister_self
            
                optional_parameters :initial_value, :value, :assert, :asserted_value
                mutually_exclusive_parameters :initial_value, :value
            Severity: Minor
            Found in lib/bindata/base_primitive.rb - About 3 hrs to fix

              File struct.rb has 310 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'bindata/base'
              require 'bindata/delayed_io'
              
              module BinData
                class Base
              Severity: Minor
              Found in lib/bindata/struct.rb - About 3 hrs to fix

                Class SanitizedParameters has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class SanitizedParameters < Hash
                    # Memoized constants
                    BIG_ENDIAN    = SanitizedBigEndian.new
                    LITTLE_ENDIAN = SanitizedLittleEndian.new
                
                
                Severity: Minor
                Found in lib/bindata/sanitize.rb - About 2 hrs to fix

                  File sanitize.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'bindata/registry'
                  
                  module BinData
                  
                    # Subclasses of this are sanitized
                  Severity: Minor
                  Found in lib/bindata/sanitize.rb - About 2 hrs to fix

                    Class DSLParser has 22 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class DSLParser
                          def initialize(the_class, parser_type)
                            raise "unknown parser type #{parser_type}" unless parser_abilities[parser_type]
                    
                            @the_class      = the_class
                    Severity: Minor
                    Found in lib/bindata/dsl.rb - About 2 hrs to fix

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

                          class Transform
                            class << self
                              # Indicates that this transform changes the length of the
                              # underlying data. e.g. performs compression or error correction
                              def transform_changes_stream_length!
                      Severity: Minor
                      Found in lib/bindata/io.rb - About 2 hrs to fix

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

                              def sum_num_bytes_below_index(index)
                                sum = 0
                                @field_objs.each_with_index do |obj, i|
                                  next unless include_obj?(obj)
                        
                        
                        Severity: Minor
                        Found in lib/bindata/struct.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 [] has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def [](arg1, arg2 = nil)
                              if arg1.respond_to?(:to_int) && arg2.nil?
                                slice_index(arg1.to_int)
                              elsif arg1.respond_to?(:to_int) && arg2.respond_to?(:to_int)
                                slice_start_length(arg1.to_int, arg2.to_int)
                        Severity: Minor
                        Found in lib/bindata/array.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 ensure_valid_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def ensure_valid_name(name)
                                if name && !option?(:fieldnames_are_values)
                                  if malformed_name?(name)
                                    raise SyntaxError, "field '#{name}' is an illegal fieldname"
                                  end
                        Severity: Minor
                        Found in lib/bindata/dsl.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 do_write has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def do_write(io)
                                offset = 0
                                instantiate_all_objs
                                @field_objs.each do |f|
                                  next unless include_obj?(f)
                        Severity: Minor
                        Found in lib/bindata/struct.rb - About 55 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 normalize_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def normalize_name(name, hints)
                              name = underscore_name(name)
                        
                              if !registered?(name)
                                search_prefix = [""] + Array(hints[:search_prefix])
                        Severity: Minor
                        Found in lib/bindata/registry.rb - About 55 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 do_read has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def do_read(io)
                                offset = 0
                                instantiate_all_objs
                                @field_objs.each do |f|
                                  next unless include_obj?(f)
                        Severity: Minor
                        Found in lib/bindata/struct.rb - About 55 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 read_and_return_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def read_and_return_value(io)
                                prototype = get_parameter(:until_valid)
                                validator = prototype.instantiate(nil, self)
                                fs = fast_search_for_obj(validator)
                        
                        
                        Severity: Minor
                        Found in lib/bindata/skip.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 pack_directive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def pack_directive(nbits, endian, signed)
                                nwords = nbits / bits_per_word(nbits)
                        
                                directives = { 8 => 'C', 16 => 'S', 32 => 'L', 64 => 'Q' }
                        
                        
                        Severity: Minor
                        Found in lib/bindata/int.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 sum_num_bytes_below_index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def sum_num_bytes_below_index(index)
                              (0...index).inject(0) do |sum, i|
                                obj = @field_objs[i]
                                if include_obj?(obj)
                                  nbytes = obj.do_num_bytes
                        Severity: Minor
                        Found in lib/bindata/struct.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

                        Severity
                        Category
                        Status
                        Source
                        Language