weirdpercent/lyracyst

View on GitHub

Showing 5 of 14 total issues

Method get_word has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def get_word(search, func, params, result)
      prefix = 'http://api.wordnik.com:80/v4/word.json/'
      word, pcont = "#{prefix}#{search}/#{func}?", []
      params.map { |k, v|
        if k == :canon then pcont.push "useCanonical=#{v}&"; end
Severity: Minor
Found in lib/lyracyst/wordnik/word.rb - About 3 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 scrape has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def scrape(search, params, result)
      prefix = 'http://wordsmith.org/anagram/anagram.cgi?anagram='
      word, pcont = "#{prefix}#{search}", []
      params.map { |k, v|
        if k == :lang then pcont.push "&language=#{v}"; end # string
Severity: Minor
Found in lib/lyracyst/wordsmith.rb - About 3 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 fetch has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def fetch(search, source)
        label, result = 'Onelook', nil
        Lyracyst.label(label)
        fe = Lyracyst::Onelook.new
        result = fe.get_word(search, result)
Severity: Minor
Found in lib/lyracyst/onelook.rb - About 1 hr to fix

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

        def scrape(search, params, result)
          prefix = 'http://wordsmith.org/anagram/anagram.cgi?anagram='
          word, pcont = "#{prefix}#{search}", []
          params.map { |k, v|
            if k == :lang then pcont.push "&language=#{v}"; end # string
    Severity: Minor
    Found in lib/lyracyst/wordsmith.rb - About 1 hr to fix

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

            def origin_extra(result)
              ee = Lyracyst::Wordnik::Origin.new
              a, b, label = 0, result.length - 1, 'Etymology'
              while a <= b
                xml = result[a]
      Severity: Minor
      Found in lib/lyracyst/wordnik/origin.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