opennorth/scraperwiki-api-ruby

View on GitHub

Showing 9 of 9 total issues

File matchers.rb has 609 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'time'

require 'rspec'
require 'yajl'

Severity: Major
Found in lib/scraperwiki-api/matchers.rb - About 1 day to fix

    Method mismatches has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

            def mismatches
              counts = Hash.new 0
              if @subfield
                items.each do |item|
                  unless blank? item[@field]
    Severity: Minor
    Found in lib/scraperwiki-api/matchers.rb - About 5 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 matcher has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

            def matcher(meth)
              if @subfield
                items.send(meth) do |item|
                  if blank? item[@field]
                    meth == :reject
    Severity: Minor
    Found in lib/scraperwiki-api/matchers.rb - About 5 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

    Class API has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class API
        # @example
        #   require 'scraperwiki-api'
        #   api = ScraperWiki::API.new
        #
    Severity: Minor
    Found in lib/scraperwiki-api/matchers.rb - About 2 hrs to fix

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

              def matcher(meth)
                if @subfield
                  items.send(meth) do |item|
                    if blank? item[@field]
                      meth == :reject
      Severity: Minor
      Found in lib/scraperwiki-api/matchers.rb - About 1 hr to fix

        Method mismatches has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def mismatches
                  counts = Hash.new 0
                  if @subfield
                    items.each do |item|
                      unless blank? item[@field]
        Severity: Minor
        Found in lib/scraperwiki-api/matchers.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                              if Hash === w
                                if blank? w[@subfield]
                                  meth == :reject
                                else
                                  match? w[@subfield]
          Severity: Major
          Found in lib/scraperwiki-api/matchers.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if Hash === w
                                  unless blank? w[@subfield]
                                    counts[w[@subfield]] += 1
                                  end
                                else
            Severity: Major
            Found in lib/scraperwiki-api/matchers.rb - About 45 mins to fix

              Method match? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def match?(v)
                        w = Yajl::Parser.parse v
                        if Hash === w
                          difference(w).empty?
                        elsif Array === w
              Severity: Minor
              Found in lib/scraperwiki-api/matchers.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

              Severity
              Category
              Status
              Source
              Language