weirdpercent/oversetter

View on GitHub

Showing 16 of 16 total issues

Method get_trans has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def get_trans(search, params)
                func, result = 'translate', nil
                tran = Oversetter::Glosbe.new
                result = tran.get_word(search, func, params, result)
                if result =~ /"/i
Severity: Minor
Found in lib/oversetter/glosbe/translate.rb - About 1 hr to fix

    Method get_trans has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

                def get_trans(search, params)
                    func, result = 'translate', nil
                    tran = Oversetter::Glosbe.new
                    result = tran.get_word(search, func, params, result)
                    if result =~ /"/i
    Severity: Minor
    Found in lib/oversetter/glosbe/translate.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 get_trans has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                def get_trans(search, params)
                    func, result = 'translation', nil
                    tran = Oversetter::Hablaa.new
                    result = tran.get_word(search, func, params, result)
                    if result != 'error'
    Severity: Minor
    Found in lib/oversetter/hablaa/translate.rb - About 1 hr to fix

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

          blaa.command :ex do |example|
              example.flag :esrc, :default_value => nil, :arg_name => 'string', :desc => '3-letter ISO 693-3 source language code (Required)'
              example.flag :etar, :default_value => nil, :arg_name => 'string', :desc => '3-letter ISO 693-3 source language code (Required)'
              example.action do |global_options, options, args|
                  if args.length > 1
      Severity: Major
      Found in lib/oversetter/cli/hablaa.rb and 2 other locations - About 1 hr to fix
      lib/oversetter/cli/hablaa.rb on lines 15..26
      lib/oversetter/cli/hablaa.rb on lines 47..58

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

      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

          blaa.command :tr do |translate|
              translate.flag :src, :default_value => nil, :arg_name => 'string', :desc => '3-letter ISO 693-3 source language code (Required)'
              translate.flag :tar, :default_value => nil, :arg_name => 'string', :desc => '3-letter ISO 693-3 source language code (Required)'
              translate.action do |global_options, options, args|
                  if args.length > 1
      Severity: Major
      Found in lib/oversetter/cli/hablaa.rb and 2 other locations - About 1 hr to fix
      lib/oversetter/cli/hablaa.rb on lines 31..42
      lib/oversetter/cli/hablaa.rb on lines 47..58

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

      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

          blaa.command :si do |similar|
              similar.flag :ssrc, :default_value => nil, :arg_name => 'string', :desc => '3-letter ISO 693-3 source language code (Required)'
              similar.flag :star, :default_value => nil, :arg_name => 'string', :desc => '3-letter ISO 693-3 source language code (Required)'
              similar.action do |global_options, options, args|
                  if args.length > 1
      Severity: Major
      Found in lib/oversetter/cli/hablaa.rb and 2 other locations - About 1 hr to fix
      lib/oversetter/cli/hablaa.rb on lines 15..26
      lib/oversetter/cli/hablaa.rb on lines 31..42

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

      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/oversetter.rb and 2 other locations - About 1 hr to fix
      lib/oversetter.rb on lines 129..142
      lib/oversetter.rb on lines 148..161

      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/oversetter.rb and 2 other locations - About 1 hr to fix
      lib/oversetter.rb on lines 129..142
      lib/oversetter.rb on lines 166..179

      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/oversetter.rb and 2 other locations - About 1 hr to fix
      lib/oversetter.rb on lines 148..161
      lib/oversetter.rb on lines 166..179

      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 get_trans has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  def get_trans(search, params)
                      func, result = 'translate', nil
                      tran = Oversetter::Yandex.new
                      result = tran.get_word(search, func, params, result)
                      result = MultiJson.load(result)
      Severity: Minor
      Found in lib/oversetter/yandex/translate.rb - About 1 hr to fix

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

            def get_word(search, func, params, result)
                    search = URI.encode(search)
                    prefix = 'https://glosbe.com/gapi/'
                    word, pcont = "#{prefix}#{func}?", []
                    if func == 'translate' then pcont.push "tm=false&"; end
        Severity: Minor
        Found in lib/oversetter/glosbe/text.rb - About 55 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 get_word has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_word(search, func, params, result)
                    search = URI.encode(search)
                    prefix = 'https://translate.yandex.net/api/v1.5/tr.json/'
                    word, pcont = "#{prefix}#{func}?", []
                    if func != 'getLangs' then pcont.push "text=#{search}&"; end
        Severity: Minor
        Found in lib/oversetter/yandex/text.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 get_trans has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                    def get_trans(search, params)
                        func, result = 'translate', nil
                        tran = Oversetter::Yandex.new
                        result = tran.get_word(search, func, params, result)
                        result = MultiJson.load(result)
        Severity: Minor
        Found in lib/oversetter/yandex/translate.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

        Method get_trans has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                    def get_trans(search, params)
                        func, result = 'translation', nil
                        tran = Oversetter::Hablaa.new
                        result = tran.get_word(search, func, params, result)
                        if result != 'error'
        Severity: Minor
        Found in lib/oversetter/hablaa/translate.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

                            if pos['title'] != nil
                                print Rainbow('Part of speech|').bright
                                print "#{pos['title']}|"
                                pt = { 'pos title' => pos['title']}
                                Oversetter.tofile(pt)
        Severity: Minor
        Found in lib/oversetter/hablaa/translate.rb and 1 other location - About 20 mins to fix
        lib/oversetter/hablaa/translate.rb on lines 34..38

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

        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 pos['code'] != nil
                                print Rainbow('POS code|').bright
                                print "#{pos['code']}|"
                                pc = { 'pos code' => pos['code'] }
                                Oversetter.tofile(pc)
        Severity: Minor
        Found in lib/oversetter/hablaa/translate.rb and 1 other location - About 20 mins to fix
        lib/oversetter/hablaa/translate.rb on lines 40..44

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

        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