kaspernj/gettext_simple_rails

View on GitHub

Showing 12 of 12 total issues

Method scan_validation_errors has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def scan_validation_errors
    GettextSimpleRails::ModelInspector.model_classes do |inspector|
      clazz_snake_name = StringCases.camel_to_snake(inspector.clazz.name)
      @translations_hash["activerecord"]["errors"]["models"][clazz_snake_name] = {"attributes" => {}} unless @translations_hash["activerecord"]["errors"]["models"].key?(clazz_snake_name)
      attributes_hash = @translations_hash["activerecord"]["errors"]["models"][clazz_snake_name]["attributes"]

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 scan_relation_errors has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def scan_relation_errors
    GettextSimpleRails::ModelInspector.model_classes do |inspector|
      clazz_snake_name = StringCases.camel_to_snake(inspector.clazz.name)
      @translations_hash["activerecord"]["errors"]["models"][clazz_snake_name] = {"attributes" => {}} unless @translations_hash["activerecord"]["errors"]["models"].key?(clazz_snake_name)
      attributes_hash = @translations_hash["activerecord"]["errors"]["models"][clazz_snake_name]["attributes"]

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

  def translations
    return {
      "number" => {
        "currency" => {
          "format" => {
Severity: Minor
Found in lib/gettext_simple_rails/translators/number_translator.rb - About 2 hrs to fix

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

      def injector_recursive(gettext_simple, locale, translations, pre_path = [])
        if translations.is_a?(Hash)
          translations.each do |key, val|
            newpath = pre_path + [key]
            injector_recursive(gettext_simple, locale, val, newpath)
    Severity: Minor
    Found in lib/gettext_simple_rails/i18n_injector.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 devise_models has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def devise_models
        classes = []
        
        ::Rails.application.eager_load!
        
    Severity: Minor
    Found in lib/gettext_simple_rails/translators/devise_translator.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 translations has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def translations
        @translations_hash = {
          "activerecord" => {
            "attributes" => {}
          }
    Severity: Minor
    Found in lib/gettext_simple_rails/translators/globalize_translator.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 injector_recursive has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def injector_recursive(gettext_simple, locale, translations, pre_path = [])
        if translations.is_a?(Hash)
          translations.each do |key, val|
            newpath = pre_path + [key]
            injector_recursive(gettext_simple, locale, val, newpath)
    Severity: Minor
    Found in lib/gettext_simple_rails/i18n_injector.rb - About 1 hr to fix

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

        def inject_translator_translations(gettext_simple)
          @store_hash = {}
          
          GettextSimpleRails::Translators.load_all.each do |translator_data|
            translator = translator_data[:class].new
      Severity: Minor
      Found in lib/gettext_simple_rails/i18n_injector.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 write_recursive_translations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.write_recursive_translations(fp, translations, pre_path = [], args = {})
          if translations.is_a?(Hash)
            translations.each do |key, val|
              newpath = pre_path + [key]
              write_recursive_translations(fp, val, newpath, :comment => "Default value: #{val}")
      Severity: Minor
      Found in lib/gettext_simple_rails.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 model_classes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.model_classes
          clazzes = []
          ::Rails.application.eager_load!
          
          ::Object.constants.each do |clazz|
      Severity: Minor
      Found in lib/gettext_simple_rails/model_inspector.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 injector_recursive_array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def injector_recursive_array(gettext_simple, locale, translations, pre_path = [])
          translation_array = []
          translations.each_with_index do |val, index|
            gettext_key = "#{pre_path.join(".")}.#{index}"
            translation = gettext_simple.translate_with_locale(locale.to_s, gettext_key)
      Severity: Minor
      Found in lib/gettext_simple_rails/i18n_injector.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 newest_po_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def newest_po_file
          newest_time = nil
          newest_path = nil
          
          I18n.available_locales.each do |locale|
      Severity: Minor
      Found in lib/gettext_simple_rails/cache_handler.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