dmendel/bindata

View on GitHub
lib/bindata/dsl.rb

Summary

Maintainability
C
1 day
Test Coverage

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

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

            def set_endian(endian)
              if endian
                if fields?
                  dsl_raise SyntaxError, "endian must be called before defining fields"
                end
      Severity: Minor
      Found in lib/bindata/dsl.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

      There are no issues that match your filters.

      Category
      Status