werein/x-editable-rails

View on GitHub

Showing 4 of 4 total issues

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

        def editable(object, method, options = {})
          options = Configuration.method_options_for(object, method).deep_merge(options).with_indifferent_access
          # merge data attributes for backwards-compatibility
          options.merge! options.delete(:data){ Hash.new }

Severity: Minor
Found in lib/x-editable-rails/view_helpers.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 editable has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def editable(object, method, options = {})
          options = Configuration.method_options_for(object, method).deep_merge(options).with_indifferent_access
          # merge data attributes for backwards-compatibility
          options.merge! options.delete(:data){ Hash.new }

Severity: Major
Found in lib/x-editable-rails/view_helpers.rb - About 2 hrs to fix

    Method format_source has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def format_source(source, value)
              formatted_source = case value
                when TrueClass, FalseClass
                  if source.is_a?(Array) && source.first.is_a?(String) && source.size == 2
                    { '1' => source[0], '0' => source[1] }
    Severity: Minor
    Found in lib/x-editable-rails/view_helpers.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 format_class_options! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def format_class_options!(options)
              if class_options = options[:class_options]
                class_options.each do |class_name, methods|
                  methods.each do |method, method_options|
                    unless method_options.is_a? Hash
    Severity: Minor
    Found in lib/x-editable-rails/configuration.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