jungomi/mdn_query

View on GitHub

Showing 11 of 11 total issues

Method traverse has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def traverse
      unless @dom.css('div.nonStandard').empty?
        @current_section.append_text("\n> ***Non-standard***\n")
      end
      blacklist_level = nil
Severity: Minor
Found in lib/mdn_query/traverse_dom.rb - About 4 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

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

    def traverse
      unless @dom.css('div.nonStandard').empty?
        @current_section.append_text("\n> ***Non-standard***\n")
      end
      blacklist_level = nil
Severity: Minor
Found in lib/mdn_query/traverse_dom.rb - About 1 hr to fix

    Method max_col_sizes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def max_col_sizes
          max_sizes = @heading.map { |col| col.size > 3 ? col.size : 3 }
          @body.each do |row|
            row.each.with_index do |str, index|
              next unless str.size > max_sizes[index]
    Severity: Minor
    Found in lib/mdn_query/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 url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def url
          query_url = "#{@url}?q=#{@query}&locale=#{@locale}"
          query_url << @topics.map { |t| "&topic=#{t}" }.join
          unless @css_classnames.nil?
            query_url << "&css_classnames=#{@css_classnames}"
    Severity: Minor
    Found in lib/mdn_query/search.rb - About 25 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

          begin
            response = RestClient::Request.execute(method: :get, url: url,
                                                   headers: { accept: 'text/html' })
          rescue RestClient::Exception, SocketError => e
            raise MdnQuery::HttpRequestFailed.new(url, e),
    Severity: Minor
    Found in lib/mdn_query/document.rb and 1 other location - About 20 mins to fix
    lib/mdn_query/search_result.rb on lines 21..27

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

    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

          begin
            response = RestClient::Request.execute(method: :get, url: url,
                                                   headers: { accept: 'json' })
          rescue RestClient::Exception, SocketError => e
            raise MdnQuery::HttpRequestFailed.new(url, e),
    Severity: Minor
    Found in lib/mdn_query/search_result.rb and 1 other location - About 20 mins to fix
    lib/mdn_query/document.rb on lines 15..21

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

    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 previous_page
          if @result.nil?
            execute
          elsif @result.previous?
            query_url = url
    Severity: Minor
    Found in lib/mdn_query/search.rb and 1 other location - About 15 mins to fix
    lib/mdn_query/search.rb on lines 64..71

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

    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 next_page
          if @result.nil?
            execute
          elsif @result.next?
            query_url = url
    Severity: Minor
    Found in lib/mdn_query/search.rb and 1 other location - About 15 mins to fix
    lib/mdn_query/search.rb on lines 80..87

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

    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

    Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency codeclimate-test-reporter should appear before simplecov.
    Open

      spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
    Severity: Minor
    Found in mdn_query.gemspec by rubocop

    Dependencies in the gemspec should be alphabetically sorted.

    Example:

    # bad
    spec.add_dependency 'rubocop'
    spec.add_dependency 'rspec'
    
    # good
    spec.add_dependency 'rspec'
    spec.add_dependency 'rubocop'
    
    # good
    spec.add_dependency 'rubocop'
    
    spec.add_dependency 'rspec'
    
    # bad
    spec.add_development_dependency 'rubocop'
    spec.add_development_dependency 'rspec'
    
    # good
    spec.add_development_dependency 'rspec'
    spec.add_development_dependency 'rubocop'
    
    # good
    spec.add_development_dependency 'rubocop'
    
    spec.add_development_dependency 'rspec'
    
    # bad
    spec.add_runtime_dependency 'rubocop'
    spec.add_runtime_dependency 'rspec'
    
    # good
    spec.add_runtime_dependency 'rspec'
    spec.add_runtime_dependency 'rubocop'
    
    # good
    spec.add_runtime_dependency 'rubocop'
    
    spec.add_runtime_dependency 'rspec'
    
    # good only if TreatCommentsAsGroupSeparators is true
    # For code quality
    spec.add_dependency 'rubocop'
    # For tests
    spec.add_dependency 'rspec'

    Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency minitest should appear before rake.
    Open

      spec.add_development_dependency 'minitest', '~> 5.0'
    Severity: Minor
    Found in mdn_query.gemspec by rubocop

    Dependencies in the gemspec should be alphabetically sorted.

    Example:

    # bad
    spec.add_dependency 'rubocop'
    spec.add_dependency 'rspec'
    
    # good
    spec.add_dependency 'rspec'
    spec.add_dependency 'rubocop'
    
    # good
    spec.add_dependency 'rubocop'
    
    spec.add_dependency 'rspec'
    
    # bad
    spec.add_development_dependency 'rubocop'
    spec.add_development_dependency 'rspec'
    
    # good
    spec.add_development_dependency 'rspec'
    spec.add_development_dependency 'rubocop'
    
    # good
    spec.add_development_dependency 'rubocop'
    
    spec.add_development_dependency 'rspec'
    
    # bad
    spec.add_runtime_dependency 'rubocop'
    spec.add_runtime_dependency 'rspec'
    
    # good
    spec.add_runtime_dependency 'rspec'
    spec.add_runtime_dependency 'rubocop'
    
    # good
    spec.add_runtime_dependency 'rubocop'
    
    spec.add_runtime_dependency 'rspec'
    
    # good only if TreatCommentsAsGroupSeparators is true
    # For code quality
    spec.add_dependency 'rubocop'
    # For tests
    spec.add_dependency 'rspec'

    Unnecessary utf-8 encoding comment.
    Open

    # coding: utf-8
    Severity: Minor
    Found in mdn_query.gemspec by rubocop
    Severity
    Category
    Status
    Source
    Language