shioyama/mobility

View on GitHub

Showing 7 of 30 total issues

Method included has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
Open

      def self.included(base)
        base.class_eval do
          plugin :validation_helpers

          # Paraphased from sequel_polymorphic gem
Severity: Minor
Found in lib/mobility/sequel/translation.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 prepare_for_invocation has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

    def self.prepare_for_invocation(name, value)
      if name == :backend
        if SUPPORTED_BACKENDS.include?(value)
          require_relative "./backend_generators/#{value}_backend"
          Mobility::BackendGenerators.const_get("#{value}_backend".camelcase.freeze)
Severity: Minor
Found in lib/rails/generators/mobility/translations_generator.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 serializer_for has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
Open

        def serializer_for(format)
          lambda do |obj|
            return if obj.nil?
            if obj.is_a? ::Hash
              obj = obj.inject({}) do |translations, (locale, value)|
Severity: Minor
Found in lib/mobility/backends/serialized.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 define_read has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
Open

        def define_read(fallbacks)
          define_method :read do |locale, fallback: true, **options|
            return super(locale, options) if !fallback || options[:locale]

            locales = fallback == true ? fallbacks[locale] : [locale, *fallback]
Severity: Minor
Found in lib/mobility/plugins/fallbacks.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

Shadowing outer local variable - id_map.
Open

              id_map.each do |klass_name, id_map|
Severity: Minor
Found in lib/mobility/sequel/translation.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

Shadowing outer local variable - model.
Open

              eo[:rows].each do |model|
Severity: Minor
Found in lib/mobility/sequel/translation.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

Shadowing outer local variable - model.
Open

                  id_map[related_obj.pk].each do |model|
Severity: Minor
Found in lib/mobility/sequel/translation.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end
Severity
Category
Status
Source
Language