makandra/assignable_values

View on GitHub

Showing 6 of 6 total issues

Class Base has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Base

        attr_reader :model, :property, :options, :values, :default, :secondary_default

        SUPPORTED_OPTIONS = [
Severity: Minor
Found in lib/assignable_values/active_record/restriction/base.rb - About 4 hrs to fix

    Method define_humanized_value_instance_method has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

            def define_humanized_value_instance_method
              restriction = self
              multiple = @options[:multiple]
              enhance_model do
                define_method :"humanized_#{restriction.property.to_s.singularize}" do |*args|
    Severity: Minor
    Found in lib/assignable_values/active_record/restriction/scalar_attribute.rb - About 2 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

    File base.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module AssignableValues
      module ActiveRecord
        module Restriction
          class Base
    
    
    Severity: Minor
    Found in lib/assignable_values/active_record/restriction/base.rb - About 2 hrs to fix

      Method assignable_values has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def assignable_values(record, options = {})
                additional_assignable_values = []
                current_values = assignable_values_from_record_or_delegate(record)
      
                if options.fetch(:include_old_value, true) && has_previously_saved_value?(record)
      Severity: Minor
      Found in lib/assignable_values/active_record/restriction/base.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 set_default has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def set_default(record)
                if record.new_record? && record.send(property).nil?
                  default_value = evaluate_default(record, default)
                  begin
                    if secondary_default? && !assignable_value?(record, default_value)
      Severity: Minor
      Found in lib/assignable_values/active_record/restriction/base.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 validate_record has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def validate_record(record)
                value = current_value(record)
                unless allow_blank?(record) && value.blank?
                  begin
                    unless assignable_value?(record, value)
      Severity: Minor
      Found in lib/assignable_values/active_record/restriction/base.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

      Severity
      Category
      Status
      Source
      Language