molybdenum-99/infoboxer

View on GitHub

Showing 53 of 53 total issues

File table_spec.rb has 458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'infoboxer/parser'

module Infoboxer
  describe Parser, 'tables' do
    let(:ctx) { Parser::Context.new(unindent(source)) }
Severity: Minor
Found in spec/infoboxer/parser/table_spec.rb - About 7 hrs to fix

    Class Context has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Context # rubocop:disable Metrics/ClassLength
          attr_reader :lineno
          attr_reader :traits
    
          def initialize(text, traits = nil)
    Severity: Minor
    Found in lib/infoboxer/parser/context.rb - About 2 hrs to fix

      Class Node has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Node
            def initialize(**params)
              @params = params
            end
      
      
      Severity: Minor
      Found in lib/infoboxer/tree/node.rb - About 2 hrs to fix

        Method long_inline has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def long_inline(until_pattern = nil)
                nodes = Nodes[]
                guarded_loop do
                  chunk = @context.scan_until(re.inline_until_cache[until_pattern])
                  nodes << chunk
        Severity: Minor
        Found in lib/infoboxer/parser/inline.rb - About 2 hrs 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

        File inline_spec.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'infoboxer/parser'
        
        module Infoboxer
          describe Parser, 'inline markup' do
            let(:ctx) { Parser::Context.new(source) }
        Severity: Minor
        Found in spec/infoboxer/parser/inline_spec.rb - About 2 hrs to fix

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

                def inline(until_pattern = nil)
                  start = @context.lineno
                  nodes = Nodes[]
                  guarded_loop do
                    chunk = @context.scan_until(re.inline_until_cache[until_pattern])
          Severity: Minor
          Found in lib/infoboxer/parser/inline.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 template_vars has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def template_vars
                  log 'Parsing template variables'
          
                  num = 1
                  res = Nodes[]
          Severity: Minor
          Found in lib/infoboxer/parser/template.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 inline_formatting has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def inline_formatting(match) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/AbcSize
                  case match
                  when "'''''"
                    BoldItalic.new(short_inline(/'''''/))
                  when "'''"
          Severity: Minor
          Found in lib/infoboxer/parser/inline.rb - About 1 hr to fix

            Method parse_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_params(str)
                    return {} unless str
            
                    scan = StringScanner.new(str)
                    params = {}
            Severity: Minor
            Found in lib/infoboxer/parser/util.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 scan_step has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def scan_step(scanner) # rubocop:disable Metrics/PerceivedComplexity
                    op = scanner.scan(%r{//?}) or unexpected(scanner, '/')
                    type = scanner.scan(/[A-Za-z_]*/)
                    attrs = {}
                    while scanner.scan(/\[/)
            Severity: Minor
            Found in lib/infoboxer/wiki_path.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 gallery has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def gallery(tag_rest)
                    params = parse_params(tag_rest)
                    images = []
                    guarded_loop do
                      @context.next! if @context.eol?
            Severity: Minor
            Found in lib/infoboxer/parser/inline.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 short_inline has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def short_inline(until_pattern = nil)
                    nodes = Nodes[]
                    guarded_loop do
                      # FIXME: quick and UGLY IS HELL JUST TRYING TO MAKE THE SHIT WORK
                      chunk =
            Severity: Minor
            Found in lib/infoboxer/parser/inline.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 table_cells has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def table_cells(table, cell_class = TableCell)
                    log 'Table cells found'
                    table.push_children(TableRow.new) unless table.children.last.is_a?(TableRow)
                    row = table.children.last
            
            
            Severity: Minor
            Found in lib/infoboxer/parser/table.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 << has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def <<(node) # rubocop:disable Metrics/PerceivedComplexity
                    if node.is_a?(Array)
                      node.each { |n| self << n }
                    elsif last&.can_merge?(node)
                      last.merge!(node)
            Severity: Minor
            Found in lib/infoboxer/tree/nodes.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 in_sections has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def in_sections
                      return parent.in_sections unless parent.is_a?(Tree::Document)
                      return @in_sections if @in_sections
            
                      heading =
            Severity: Minor
            Found in lib/infoboxer/navigation/sections.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

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

                describe :lookup_next_siblings do
                  let!(:node) { document.lookup(Tree::ListItem, text: /deep test/).first }
            
                  it 'works' do
                    expect(node.lookup_next_siblings(text: /cool/).count).to eq 0
            Severity: Minor
            Found in spec/infoboxer/navigation/lookup_spec.rb and 1 other location - About 45 mins to fix
            spec/infoboxer/navigation/lookup_spec.rb on lines 184..189

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

            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

                describe :lookup_prev_siblings do
                  let!(:node) { document.lookup(Tree::ListItem, text: /deep test/).first }
            
                  it 'works' do
                    expect(node.lookup_prev_siblings(text: /cool/).count).to eq 1
            Severity: Minor
            Found in spec/infoboxer/navigation/lookup_spec.rb and 1 other location - About 45 mins to fix
            spec/infoboxer/navigation/lookup_spec.rb on lines 193..198

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

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

                  context 'in first row' do
                    let(:source) {
                      %{
                      {|
                      ! one
            Severity: Major
            Found in spec/infoboxer/parser/table_spec.rb and 3 other locations - About 40 mins to fix
            spec/infoboxer/parser/table_spec.rb on lines 195..208
            spec/infoboxer/parser/table_spec.rb on lines 212..225
            spec/infoboxer/parser/table_spec.rb on lines 229..244

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

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

                  context 'several headers in line' do
                    let(:source) {
                      %{
                      {|
                      ! one||two||three
            Severity: Major
            Found in spec/infoboxer/parser/table_spec.rb and 3 other locations - About 40 mins to fix
            spec/infoboxer/parser/table_spec.rb on lines 155..170
            spec/infoboxer/parser/table_spec.rb on lines 212..225
            spec/infoboxer/parser/table_spec.rb on lines 229..244

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

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

                  context 'in the middle of a row' do
                    let(:source) {
                      %{
                      {|
                      | one
            Severity: Major
            Found in spec/infoboxer/parser/table_spec.rb and 3 other locations - About 40 mins to fix
            spec/infoboxer/parser/table_spec.rb on lines 155..170
            spec/infoboxer/parser/table_spec.rb on lines 195..208
            spec/infoboxer/parser/table_spec.rb on lines 212..225

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

            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

            Severity
            Category
            Status
            Source
            Language