r18n/r18n-core

View on GitHub

Showing 27 of 27 total issues

Method pluralize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def pluralize(number)
        return 0 if number.zero?

        case number % 10
        when 1
Severity: Minor
Found in lib/r18n-core/locales/pl.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 == has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def ==(other)
      return false unless other.is_a? Untranslated
      return false unless locale            == other.locale
      return false unless translated_path   == other.translated_path
      return false unless untranslated_path == other.untranslated_path
Severity: Minor
Found in lib/r18n-core/untranslated.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 pluralize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def pluralize(number)
        if number.zero?
          0
        elsif number == 1
          1
Severity: Minor
Found in lib/r18n-core/locales/ar.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

Avoid too many return statements within this method.
Open

            return send unlocalized[code], *params
Severity: Major
Found in lib/r18n-core/translated.rb - About 30 mins to fix

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

          def pluralize(number)
            if number.zero?
              0
            elsif number % 10 == 1 && number % 100 != 11
              1
    Severity: Minor
    Found in lib/r18n-core/locales/ru.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

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

        def change(locale)
          locale = locale.code if locale.is_a? Locale
          exists = get ? get.locales.map(&:code) : []
          places = get ? get.translation_places : R18n.default_places
    
    
    Severity: Minor
    Found in lib/r18n-core.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

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

        def initialize_types
          return unless defined?(Psych)
    
          Filters.by_type.each_key do |type|
            next unless type.is_a? String
    Severity: Minor
    Found in lib/r18n-core/yaml_methods.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