irobayna/stupidedi

View on GitHub

Showing 292 of 292 total issues

Method process has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def process
    params = []

    if m = MATCH_A.match(statement.tokens.to_s)
      name = m.captures.first
Severity: Minor
Found in build/doc/lib/meta-plugin/lib/yard-meta/legacy.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 2 locations. Consider refactoring.
Open

      def pretty_print(q)
        q.text("LoopDef[#{@id}]")
        q.group(2, "(", ")") do
          q.breakable ""
          @header_segment_uses.each do |e|
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 111..134

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

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 pretty_print(q)
        q.text("TableDef[#{@id}]")
        q.group(2, "(", ")") do
          q.breakable ""
          @header_segment_uses.each do |e|
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 105..128

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

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

      def mksegment_tok(segment_dict, id, elements, position)
        id = id.to_sym
        element_toks = []

        unless segment_dict.defined_at?(id)
Severity: Minor
Found in lib/stupidedi/parser/tokenization.rb - About 1 hr to fix

    Method hipaa has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def hipaa(base = default)
          base.customize do |c|
            c.transaction_set.customize do |x|
              x.register("004010",       "HP", "835") { Stupidedi::TransactionSets::FortyTen::Standards::HP835 }
              x.register("004010X091A1", "HP", "835") { Stupidedi::TransactionSets::FortyTen::Implementations::X091A1::HP835 }
    Severity: Minor
    Found in lib/stupidedi/config.rb - About 1 hr to fix

      Method mod_element has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def mod_element(element_use, descriptor, requirement, name, arguments)
              unless requirement.is_a?(Schema::ElementReq)
                raise Exceptions::InvalidSchemaError,
                  "first argument to Element must be a Schema::ElementReq but got #{requirement.inspect} for #{descriptor}"
              end
      Severity: Minor
      Found in lib/stupidedi/transaction_sets/builder.rb - About 1 hr to fix

        Method build_distinct has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

                def build_distinct(total, n, m, instructions)
                  if total.finite?
                    # The sum of all allowed value sets is finite, so we know that each
                    # individual allowed value set is finite (we can iterate over it).
                    map = Hash.new{|h,k| h[k] = [] }
        Severity: Minor
        Found in lib/stupidedi/parser/constraint_table.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_segment has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def read_segment
                consume_control_chars.flatmap do |start|
                  # We might start reading a segment at "\nNM1...", where the "\n" is on
                  # line 5, but "NM1" is on line 6. So to ensure the segment position is
                  # line 6, we start with consume_control_characters.
        Severity: Minor
        Found in lib/stupidedi/reader/token_reader.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 build_disjoint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

                def build_disjoint(total, n, m, instructions)
                  if total.finite?
                    # The sum of all allowed value sets is finite, so we know that each
                    # individual allowed value set is finite (we can iterate over it).
                    map = Hash.new
        Severity: Minor
        Found in lib/stupidedi/parser/constraint_table.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 count has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def count(*args)
                if block_given?
                  inject(0){|n, e| yield(e) ? n + 1 : n }
                elsif args.empty?
                  size
        Severity: Minor
        Found in lib/ruby/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

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

              def delete
                if not last?
                  # Move to `next`
                  head, *tail = @path.right
        
        
        Severity: Major
        Found in lib/stupidedi/zipper/memoized_cursor.rb and 1 other location - About 1 hr to fix
        lib/stupidedi/zipper/edited_cursor.rb on lines 130..150

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

        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

              def delete
                if not last?
                  # Move to `next`
                  head, *tail = @path.right
        
        
        Severity: Major
        Found in lib/stupidedi/zipper/edited_cursor.rb and 1 other location - About 1 hr to fix
        lib/stupidedi/zipper/memoized_cursor.rb on lines 106..126

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

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

              def consume_prefix(s)
                return success(self) if s.empty?
        
                position = 0
                buffer   = ""
        Severity: Minor
        Found in lib/stupidedi/reader/token_reader.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 parent has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def parent
                active = []
        
                @active.each do |zipper|
                  state = zipper
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.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 between has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def between(other)
                # Collect ancestors of self, sorted oldest first (deepest last). This
                # forms a boundary of nodes, which is called a "spine" below
                zipper = self
                lspine = [self]
        Severity: Minor
        Found in lib/stupidedi/zipper/abstract_cursor.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 process has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def process
            name = statement.parameters.first.jump(:symbol, :ident).source.slice(1..-1)
            args = statement.parameters.jump(:assoc)
            params = []
        
        
        Severity: Minor
        Found in build/doc/lib/meta-plugin/lib/yard-meta/handler.rb - About 1 hr to fix

          Method basis has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def basis(instructions, mode)
                    @__basis[mode] ||= begin
                      # When inserting segments, given a choice between two otherwise
                      # equivalent instructions, prefer the one with smallest `pop_count`.
                      # For example, when inserting an HL*20 in X221 835, the new 2000A
          Severity: Minor
          Found in lib/stupidedi/parser/constraint_table.rb - About 1 hr to fix

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

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

              Method tsequence has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def tsequence(table_defs, offset = 0)
                      instructions = []
                      buffer       = []
                      last         = nil
              
              
              Severity: Minor
              Found in lib/stupidedi/parser/states/abstract_state.rb - About 1 hr to fix

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

                        def optional_elements(disjoint, instructions)
                          designators = []
                
                          disjoint.each do |(m, n), map|
                            required = true
                Severity: Minor
                Found in lib/stupidedi/transaction_sets/validation/ambiguity.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

                Severity
                Category
                Status
                Source
                Language