kaspernj/acts_as_customized_attributes

View on GitHub

Showing 5 of 5 total issues

Method acts_as_customized_attributes has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def acts_as_customized_attributes(_args = {})
    $aaca_class_name_key = "#{name}DataKey"
    $aaca_class_name_data = "#{name}Data"
    $original_class_name = name

Severity: Major
Found in lib/acts_as_customized_attributes/class_methods.rb - About 3 hrs to fix

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

      def update_customized_attributes_with_args(args)
        args.each { |key, _value| raise "Invalid argument: '#{key}'." unless UPDATE_CUSTOMIZED_ATTRIBUTES_VALID_ARGS.include?(key) }
    
        args.fetch(:data).each do |key, value|
          begin
    Severity: Minor
    Found in lib/acts_as_customized_attributes/instance_methods.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 migration_class has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def migration_class
        $acts_as_customized_attributes_keys_table_name = "#{name.tableize.singularize.tr("/", "_")}_data_keys"
        $acts_as_customized_attributes_table_name = "#{name.tableize.singularize.tr("/", "_")}_data"
        $table_name = table_name
    
    
    Severity: Minor
    Found in lib/acts_as_customized_attributes/class_methods.rb - About 1 hr to fix

      Method acts_as_customized_attributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def acts_as_customized_attributes(_args = {})
          $aaca_class_name_key = "#{name}DataKey"
          $aaca_class_name_data = "#{name}Data"
          $original_class_name = name
      
      
      Severity: Minor
      Found in lib/acts_as_customized_attributes/class_methods.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 associated_resource_and_data_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def associated_resource_and_data_key
              return errors.add :data_key_id, "not valid" unless data_key_id?
      
              if !resource_id? || !resource
                return errors.add :resource_id, "not associated"
      Severity: Minor
      Found in lib/acts_as_customized_attributes/class_methods.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