rubysolo/andrey

View on GitHub

Showing 6 of 6 total issues

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

  module Language
    class English
      def self.symbols
        ('a'..'z').to_a
      end
Severity: Major
Found in lib/andrey/language/english.rb and 1 other location - About 2 days to fix
lib/andrey/language/american_names.rb on lines 2..36

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

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

  module Language
    class AmericanNames
      def self.symbols
        ('a'..'z').to_a
      end
Severity: Major
Found in lib/andrey/language/american_names.rb and 1 other location - About 2 days to fix
lib/andrey/language/english.rb on lines 2..36

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

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

      def self.probability_map
        [
          [0.0007,0.0455,0.0631,0.0299,0.0239,0.0068,0.0277,0.0043,0.0197,0.0009,0.0102,0.1412,0.0378,0.1417,0.0014,0.0362,0.0010,0.1074,0.0503,0.1367,0.0178,0.0105,0.0057,0.0045,0.0076,0.0045],
          [0.1310,0.0229,0.0052,0.0078,0.1358,0.0018,0.0011,0.0028,0.1382,0.0041,0.0003,0.2168,0.0036,0.0019,0.1016,0.0029,0.0001,0.0996,0.0198,0.0073,0.0698,0.0020,0.0012,0.0000,0.0102,0.0001],
          [0.1470,0.0001,0.0147,0.0002,0.1015,0.0000,0.0000,0.1287,0.0705,0.0000,0.0357,0.0316,0.0003,0.0016,0.1555,0.0001,0.0009,0.0532,0.0046,0.0671,0.0494,0.0000,0.0001,0.0000,0.0272,0.0003],
Severity: Minor
Found in lib/andrey/language/english.rb - About 1 hr to fix

    Method probability_map has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.probability_map
            [
              [125,740,1698,1357,901,163,596,623,910,39,405,4917,4716,12334,40,306,32,13076,2427,3008,1576,1507,612,109,1479,306],
              [1865,442,9,7,4329,0,0,3,732,3,0,510,0,8,1108,0,0,2391,231,8,711,2,0,0,389,0],
              [3012,23,501,119,2046,36,125,5389,1170,2,2232,914,59,73,2585,20,105,651,9,169,383,4,9,0,532,10],
    Severity: Minor
    Found in lib/andrey/language/american_names.rb - About 1 hr to fix

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

          def self.analyze_text(text, include_spaces=false)
            pmap = {}
      
            text.downcase.chars.each_cons(2) do |from, to|
              pmap[from] ||= Hash.new(0)
      Severity: Minor
      Found in lib/andrey/analyzer.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def run(*args)
              # turn cli stuffs into ruby stuffs
              options = {}
              args.each_cons(2) do |(flag, value)|
                options[:length] = value.to_i if flag == '-l'
      Severity: Minor
      Found in lib/andrey/command.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

      Severity
      Category
      Status
      Source
      Language