irobayna/stupidedi

View on GitHub

Showing 292 of 292 total issues

Method value has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def value(object, usage, position)
            if object.is_a?(DateVal)
              object#.copy(:usage => usage, :position => position)
            elsif object.blank?
              self::Empty.new(usage, position)
Severity: Minor
Found in lib/stupidedi/versions/common/element_types/dt.rb - About 1 hr to fix

    Method contrib has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def contrib(base = default)
          base.customize do |c|
            c.transaction_set.customize do |x|
              x.register("002001", "SH", "856") { Stupidedi::TransactionSets::TwoThousandOne::Standards::SH856 }
              x.register("002001", "PO", "830") { Stupidedi::TransactionSets::TwoThousandOne::Standards::PO830 }
    Severity: Minor
    Found in lib/stupidedi/config.rb - About 1 hr to fix

      Method read_segment_id has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def read_segment_id
              position = 0
              buffer   = ""
      
              while true
      Severity: Minor
      Found in lib/stupidedi/reader/token_reader.rb - About 1 hr to fix

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

            class TransactionSetState < AbstractState
              # @return [Reader::Separators]
              attr_reader :separators
        
              # @return [Reader::SegmentDict]
        Severity: Major
        Found in lib/stupidedi/parser/states/transaction_set_state.rb and 6 other locations - About 1 hr to fix
        lib/stupidedi/parser/states/failure_state.rb on lines 6..33
        lib/stupidedi/parser/states/initial_state.rb on lines 6..34
        lib/stupidedi/parser/states/interchange_state.rb on lines 6..34
        lib/stupidedi/parser/states/loop_state.rb on lines 6..34
        lib/stupidedi/parser/states/table_state.rb on lines 6..34
        lib/stupidedi/parser/states/transmission_state.rb on lines 6..34

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

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

            class TableState < AbstractState
              # @return [Reader::Separators]
              attr_reader :separators
        
              # @return [Reader::SegmentDict]
        Severity: Major
        Found in lib/stupidedi/parser/states/table_state.rb and 6 other locations - About 1 hr to fix
        lib/stupidedi/parser/states/failure_state.rb on lines 6..33
        lib/stupidedi/parser/states/initial_state.rb on lines 6..34
        lib/stupidedi/parser/states/interchange_state.rb on lines 6..34
        lib/stupidedi/parser/states/loop_state.rb on lines 6..34
        lib/stupidedi/parser/states/transaction_set_state.rb on lines 6..34
        lib/stupidedi/parser/states/transmission_state.rb on lines 6..34

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

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

            class FailureState < AbstractState
              # @return [Reader::Separators]
              attr_reader :separators
        
              # @return [Reader::SegmentDict]
        Severity: Major
        Found in lib/stupidedi/parser/states/failure_state.rb and 6 other locations - About 1 hr to fix
        lib/stupidedi/parser/states/initial_state.rb on lines 6..34
        lib/stupidedi/parser/states/interchange_state.rb on lines 6..34
        lib/stupidedi/parser/states/loop_state.rb on lines 6..34
        lib/stupidedi/parser/states/table_state.rb on lines 6..34
        lib/stupidedi/parser/states/transaction_set_state.rb on lines 6..34
        lib/stupidedi/parser/states/transmission_state.rb on lines 6..34

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

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

            class LoopState < AbstractState
              # @return [Reader::Separators]
              attr_reader :separators
        
              # @return [Reader::SegmentDict]
        Severity: Major
        Found in lib/stupidedi/parser/states/loop_state.rb and 6 other locations - About 1 hr to fix
        lib/stupidedi/parser/states/failure_state.rb on lines 6..33
        lib/stupidedi/parser/states/initial_state.rb on lines 6..34
        lib/stupidedi/parser/states/interchange_state.rb on lines 6..34
        lib/stupidedi/parser/states/table_state.rb on lines 6..34
        lib/stupidedi/parser/states/transaction_set_state.rb on lines 6..34
        lib/stupidedi/parser/states/transmission_state.rb on lines 6..34

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

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

            class InterchangeState < AbstractState
              # @return [Reader::Separators]
              attr_reader :separators
        
              # @return [Reader::SegmentDict]
        Severity: Major
        Found in lib/stupidedi/parser/states/interchange_state.rb and 6 other locations - About 1 hr to fix
        lib/stupidedi/parser/states/failure_state.rb on lines 6..33
        lib/stupidedi/parser/states/initial_state.rb on lines 6..34
        lib/stupidedi/parser/states/loop_state.rb on lines 6..34
        lib/stupidedi/parser/states/table_state.rb on lines 6..34
        lib/stupidedi/parser/states/transaction_set_state.rb on lines 6..34
        lib/stupidedi/parser/states/transmission_state.rb on lines 6..34

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

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

            class InitialState < AbstractState
              # @return [Reader::Separators]
              attr_reader :separators
        
              # @return [Reader::SegmentDict]
        Severity: Major
        Found in lib/stupidedi/parser/states/initial_state.rb and 6 other locations - About 1 hr to fix
        lib/stupidedi/parser/states/failure_state.rb on lines 6..33
        lib/stupidedi/parser/states/interchange_state.rb on lines 6..34
        lib/stupidedi/parser/states/loop_state.rb on lines 6..34
        lib/stupidedi/parser/states/table_state.rb on lines 6..34
        lib/stupidedi/parser/states/transaction_set_state.rb on lines 6..34
        lib/stupidedi/parser/states/transmission_state.rb on lines 6..34

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

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

            class TransmissionState < AbstractState
              # @return [Reader::Separators]
              attr_reader :separators
        
              # @return [Reader::SegmentDict]
        Severity: Major
        Found in lib/stupidedi/parser/states/transmission_state.rb and 6 other locations - About 1 hr to fix
        lib/stupidedi/parser/states/failure_state.rb on lines 6..33
        lib/stupidedi/parser/states/initial_state.rb on lines 6..34
        lib/stupidedi/parser/states/interchange_state.rb on lines 6..34
        lib/stupidedi/parser/states/loop_state.rb on lines 6..34
        lib/stupidedi/parser/states/table_state.rb on lines 6..34
        lib/stupidedi/parser/states/transaction_set_state.rb on lines 6..34

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

        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 prev has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def prev(count = 1)
                unless count > 0
                  raise ArgumentError,
                    "count must be positive"
                end
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.rb - About 1 hr to fix

          Method next has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def next(count = 1)
                  unless count > 0
                    raise ArgumentError,
                      "count must be positive"
                  end
          Severity: Minor
          Found in lib/stupidedi/parser/navigation.rb - About 1 hr to fix

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

                  def initialize(id, repeat_count, header_segment_uses, loop_defs, trailer_segment_uses, parent)
                    @id, @repeat_count, @header_segment_uses, @loop_defs, @trailer_segment_uses, @parent =
                      id, repeat_count, header_segment_uses, loop_defs, trailer_segment_uses, parent
            
                    # Delay re-parenting until the entire definition tree has a root
            Severity: Major
            Found in lib/stupidedi/schema/loop_def.rb and 1 other location - About 1 hr to fix
            lib/stupidedi/schema/table_def.rb on lines 25..34

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

            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

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

                        map = Hash.new{|h,k| h[k] = instructions }
            
                        instructions.each do |i|
                          element_use = i.segment_use.definition.element_uses.at(n)
                          unless m.nil?
            Severity: Major
            Found in lib/stupidedi/parser/constraint_table.rb and 1 other location - About 1 hr to fix
            lib/stupidedi/parser/constraint_table.rb on lines 397..415

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

            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 initialize(id, position, header_segment_uses, loop_defs, trailer_segment_uses, parent)
                    @id, @position, @header_segment_uses, @loop_defs, @trailer_segment_uses, @parent =
                      id, position, header_segment_uses, loop_defs, trailer_segment_uses, parent
            
                    # Delay re-parenting until the entire definition tree has a root
            Severity: Major
            Found in lib/stupidedi/schema/table_def.rb and 1 other location - About 1 hr to fix
            lib/stupidedi/schema/loop_def.rb on lines 35..44

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

            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

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

                        map = Hash.new{|h,k| h[k] = instructions }
            
                        instructions.each do |i|
                          element_use  = i.segment_use.definition.element_uses.at(n)
            
            
            Severity: Major
            Found in lib/stupidedi/parser/constraint_table.rb and 1 other location - About 1 hr to fix
            lib/stupidedi/parser/constraint_table.rb on lines 351..368

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

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

                      def strftime(format, value)
                        if AN::DATE_FORMAT_RANGE.defined_at?(format)
                          unless value.kind_of?(Range)              and
                                 value.end.respond_to?(:strftime)   and
                                 value.begin.respond_to?(:strftime)
            Severity: Minor
            Found in lib/stupidedi/versions/common/element_types/an.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 only has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def only(machine, depth=1)
              active = machine.active.map do |state|
                value = state.node.zipper
            
                _value = value; depth.times { _value = _value.up }
            Severity: Minor
            Found in notes/split.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 critique_occurences has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def critique_occurences(zipper, recursive)
                    occurences = Hash.new{|h,k| h[k] = 0 }
            
                    zipper.children.each do |child|
                      if child.node.respond_to?(:usage)
            Severity: Minor
            Found in lib/stupidedi/parser/builder_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 read_elements has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def read_elements(segment_id, element_uses)
                    if element_uses.empty?
                      read_simple_element
                    else
                      element_use = element_uses.head
            Severity: Minor
            Found in lib/stupidedi/reader/token_reader.rb - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language