Sage/transdifflation

View on GitHub

Showing 11 of 11 total issues

Method generate_added_diff has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_added_diff(source, target, added_diff_hash, key_trace_passed, from_locale, to_locale, add_NOT_TRANSLATED=true)

      source.each_pair { |source_key, source_value|
        key_trace = key_trace_passed.dup #each pair should have a clear copy of the same array
        key_is_symbol = source_key.instance_of? Symbol
Severity: Minor
Found in lib/transdifflation.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 rate_from_branch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def rate_from_branch(hash_from, hash_to, token, words, found)

      hash_from.each_pair{ |key, value|
        if hash_from[key.to_sym].instance_of? Hash
          if hash_to[key.to_sym]
Severity: Minor
Found in lib/transdifflation.rb - About 2 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 translate_keys_in_same_yaml has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def translate_keys_in_same_yaml(source, target, from_locale, to_locale, add_NOT_TRANSLATED=true)

      source.each_pair { |source_key, source_value|

        key_is_symbol = source_key.instance_of? Symbol
Severity: Minor
Found in lib/transdifflation.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 generate_diff_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_diff_file(yml_source_content, host_target_file, from_locale, to_locale)

      existant_yml = YAMLReader.read_YAML_from_pathfile(host_target_file)
      added_diff_hash, removed_diff_hash = Hash.new, Hash.new

Severity: Minor
Found in lib/transdifflation.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 generate_diff_file has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def generate_diff_file(yml_source_content, host_target_file, from_locale, to_locale)

      existant_yml = YAMLReader.read_YAML_from_pathfile(host_target_file)
      added_diff_hash, removed_diff_hash = Hash.new, Hash.new

Severity: Minor
Found in lib/transdifflation.rb - About 1 hr to fix

    Method generate_added_diff has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def generate_added_diff(source, target, added_diff_hash, key_trace_passed, from_locale, to_locale, add_NOT_TRANSLATED=true)
    Severity: Major
    Found in lib/transdifflation.rb - About 50 mins to fix

      Method rate_from_branch has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def rate_from_branch(hash_from, hash_to, token, words, found)
      Severity: Minor
      Found in lib/transdifflation.rb - About 35 mins to fix

        Method translate_keys_in_same_yaml has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def translate_keys_in_same_yaml(source, target, from_locale, to_locale, add_NOT_TRANSLATED=true)
        Severity: Minor
        Found in lib/transdifflation.rb - About 35 mins to fix

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

                      namespace :transdifflation do
                        desc task_desc
                        task task_name do
                          puts "\nExecuting #{task_name} ************************** "
                          comparer = Transdifflation::Comparer.new
          Severity: Minor
          Found in lib/transdifflation/railtie.rb and 1 other location - About 30 mins to fix
          lib/transdifflation/railtie.rb on lines 58..63

          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

                      namespace :transdifflation do
                        desc task_desc
                        task task_name do
                          puts "\nExecuting #{task_name} ************************** "
                          comparer = Transdifflation::Comparer.new
          Severity: Minor
          Found in lib/transdifflation/railtie.rb and 1 other location - About 30 mins to fix
          lib/transdifflation/railtie.rb on lines 69..74

          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

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

              def get_transdifflation_from_file(tag_name, path_to_yaml_relative_from_rails_root, from_locale=:en, to_locale=:es )
          
                #default values in optional params
                from_locale ||= I18n.default_locale
                to_locale ||= I18n.locale
          Severity: Minor
          Found in lib/transdifflation.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