dmendel/bindata

View on GitHub

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

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

                        module BinData
                          module Transform
                            # Transforms a zstd compressed data stream.
                            #
                            #     gem install zstd-ruby
                        Severity: Major
                        Found in lib/bindata/transform/zstd.rb and 4 other locations - About 1 hr to fix
                        lib/bindata/transform/brotli.rb on lines 3..31
                        lib/bindata/transform/lz4.rb on lines 3..31
                        lib/bindata/transform/lzma.rb on lines 3..31
                        lib/bindata/transform/xz.rb on lines 3..31

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

                        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 5 locations. Consider refactoring.
                        Open

                        module BinData
                          module Transform
                            # Transforms a xz compressed data stream.
                            #
                            #     gem install ruby-xz
                        Severity: Major
                        Found in lib/bindata/transform/xz.rb and 4 other locations - About 1 hr to fix
                        lib/bindata/transform/brotli.rb on lines 3..31
                        lib/bindata/transform/lz4.rb on lines 3..31
                        lib/bindata/transform/lzma.rb on lines 3..31
                        lib/bindata/transform/zstd.rb on lines 3..31

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

                        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 5 locations. Consider refactoring.
                        Open

                        module BinData
                          module Transform
                            # Transforms a brotli compressed data stream.
                            #
                            #     gem install brotli
                        Severity: Major
                        Found in lib/bindata/transform/brotli.rb and 4 other locations - About 1 hr to fix
                        lib/bindata/transform/lz4.rb on lines 3..31
                        lib/bindata/transform/lzma.rb on lines 3..31
                        lib/bindata/transform/xz.rb on lines 3..31
                        lib/bindata/transform/zstd.rb on lines 3..31

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

                        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 5 locations. Consider refactoring.
                        Open

                        module BinData
                          module Transform
                            # Transforms a LZ4 compressed data stream.
                            #
                            #     gem install extlz4
                        Severity: Major
                        Found in lib/bindata/transform/lz4.rb and 4 other locations - About 1 hr to fix
                        lib/bindata/transform/brotli.rb on lines 3..31
                        lib/bindata/transform/lzma.rb on lines 3..31
                        lib/bindata/transform/xz.rb on lines 3..31
                        lib/bindata/transform/zstd.rb on lines 3..31

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

                        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 5 locations. Consider refactoring.
                        Open

                        module BinData
                          module Transform
                            # Transforms a lzma compressed data stream.
                            #
                            #     gem install ruby-xz
                        Severity: Major
                        Found in lib/bindata/transform/lzma.rb and 4 other locations - About 1 hr to fix
                        lib/bindata/transform/brotli.rb on lines 3..31
                        lib/bindata/transform/lz4.rb on lines 3..31
                        lib/bindata/transform/xz.rb on lines 3..31
                        lib/bindata/transform/zstd.rb on lines 3..31

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

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

                        Severity
                        Category
                        Status
                        Source
                        Language