weirdpercent/lyracyst

View on GitHub

Showing 17 of 17 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

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

      def get_rel(search, params, reltypes)
        func, result = 'relatedWords', nil
        if reltypes != nil then params[:reltypes] = reltypes; end
        rel = Lyracyst::Wordnik.new
        result = rel.get_word(search, func, params, result)
Severity: Major
Found in lib/lyracyst/wordnik/relate.rb and 1 other location - About 1 hr to fix
lib/lyracyst/wordnik/pronounce.rb on lines 12..26

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

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 get_pro(search, params, ptype)
        func, result = 'pronunciations', nil
        if ptype != nil then params[:tformat] = ptype; end
        pron = Lyracyst::Wordnik.new
        result = pron.get_word(search, func, params, result)
Severity: Major
Found in lib/lyracyst/wordnik/pronounce.rb and 1 other location - About 1 hr to fix
lib/lyracyst/wordnik/relate.rb on lines 15..29

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

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 get_info(search, params)
        func, label, result = 'WordInfo', 'Word info', nil
        wi = Lyracyst::Rhymebrain.new
        result = wi.get_word(search, func, params, result)
        result = MultiJson.load(result)
Severity: Major
Found in lib/lyracyst/rhymebrain/info.rb and 1 other location - About 1 hr to fix
lib/lyracyst/rhymebrain/rhyme.rb on lines 10..22

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

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

        if $fmt == :json
          fo = File.new(outfile, 'w+')
          fo.print MultiJson.dump($tofile, :pretty => true)
          fo.close
          puts Rainbow("Word search was written to #{outfile}.").bright
Severity: Major
Found in lib/lyracyst.rb and 2 other locations - About 1 hr to fix
lib/lyracyst.rb on lines 137..150
lib/lyracyst.rb on lines 174..187

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

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

      if $fmt == :json
        fo = File.new(outfile, 'w+')
        fo.print MultiJson.dump($tofile, :pretty => true)
        fo.close
        puts Rainbow("Word search was written to #{outfile}.").bright
Severity: Major
Found in lib/lyracyst.rb and 2 other locations - About 1 hr to fix
lib/lyracyst.rb on lines 156..169
lib/lyracyst.rb on lines 174..187

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

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 get_rhyme(search, params)
        func, label, result = 'Rhymes', 'Rhymes', nil
        rh = Lyracyst::Rhymebrain.new
        result = rh.get_word(search, func, params, result)
        result = MultiJson.load(result)
Severity: Major
Found in lib/lyracyst/rhymebrain/rhyme.rb and 1 other location - About 1 hr to fix
lib/lyracyst/rhymebrain/info.rb on lines 10..22

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

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

      if $fmt == :json
        fo = File.open(outfile, 'w+')
        fo.print MultiJson.dump($tofile, :pretty => true)
        fo.close
        puts Rainbow("Word search was written to #{outfile}.").bright
Severity: Major
Found in lib/lyracyst.rb and 2 other locations - About 1 hr to fix
lib/lyracyst.rb on lines 137..150
lib/lyracyst.rb on lines 156..169

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

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

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

        rb.command :inf do |info|
          info.action do |global_options, options, args|
            search = args[0]
            params = { lang: options[:lang], max: options[:max] }
            info = Lyracyst::Rhymebrain::Info.new
      Severity: Minor
      Found in lib/lyracyst/cli/rhymebrain.rb and 2 other locations - About 30 mins to fix
      lib/lyracyst/cli/rhymebrain.rb on lines 7..12
      lib/lyracyst/cli/rhymebrain.rb on lines 27..32

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

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

        rb.command :rhy do |rhyme|
          rhyme.action do |global_options, options, args|
            search = args[0]
            params = { lang: options[:lang], max: options[:max] }
            rhym = Lyracyst::Rhymebrain::Rhyme.new
      Severity: Minor
      Found in lib/lyracyst/cli/rhymebrain.rb and 2 other locations - About 30 mins to fix
      lib/lyracyst/cli/rhymebrain.rb on lines 17..22
      lib/lyracyst/cli/rhymebrain.rb on lines 27..32

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

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

        rb.command :comb do |combine|
          combine.action do |global_options, options, args|
            search = args[0]
            params = { lang: options[:lang], max: options[:max] }
            port = Lyracyst::Rhymebrain::Combine.new
      Severity: Minor
      Found in lib/lyracyst/cli/rhymebrain.rb and 2 other locations - About 30 mins to fix
      lib/lyracyst/cli/rhymebrain.rb on lines 7..12
      lib/lyracyst/cli/rhymebrain.rb on lines 17..22

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

      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

              if result != nil
                st = { 'searchterm' => search }
                ty = { 'type' => 'example' }
                Lyracyst.tofile(st)
                Lyracyst.tofile(ty)
      Severity: Minor
      Found in lib/lyracyst/wordnik/example.rb and 1 other location - About 25 mins to fix
      lib/lyracyst/wordnik/define.rb on lines 24..32

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

      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

              if result != nil
                st = { 'searchterm' => search }
                type = { 'type' => 'definition' }
                Lyracyst.tofile(st)
                Lyracyst.tofile(type)
      Severity: Minor
      Found in lib/lyracyst/wordnik/define.rb and 1 other location - About 25 mins to fix
      lib/lyracyst/wordnik/example.rb on lines 16..24

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

      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