Crunch09/form_translation

View on GitHub

Showing 4 of 4 total issues

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

      def create_translated_getters(methods)
        mod = Module.new
        methods.each do |nam|
          mod.send(:define_method, nam) do
            return super() unless self.class.form_translation_locale
Severity: Minor
Found in lib/form_translation/for_model.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 input has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def input(attribute_name, options={}, &block)
      # @language is set and not default.
      options = @defaults.deep_dup.deep_merge(options) if @defaults
      input   = form_builder.send(:find_input, attribute_name, options, &block)
      input.instance_variable_set("@attribute_name", "#{self.language}_#{input.attribute_name}".to_sym)
Severity: Minor
Found in lib/form_translation/languages_form_builder.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 li_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def li_content rnd
      FormTranslation.languages.collect do |l|
        listyle = 'empty_tab' if l != FormTranslation.default_language && !object.values_given_for?(l)
        listyle = 'active' if l == FormTranslation.default_language

Severity: Minor
Found in lib/form_translation/languages_form_builder.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 language_tabs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def language_tabs rnd
      FormTranslation.languages.collect do |l|
        @language = l
        active = 'active' if l == FormTranslation.default_language
        template.content_tag(:div, class: "tab-pane #{active}", id: "#{l}_#{rnd}") do
Severity: Minor
Found in lib/form_translation/languages_form_builder.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