albertosaurus/power_enum

View on GitHub

Showing 6 of 6 total issues

File enumerated.rb has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module PowerEnum::Enumerated
  extend ActiveSupport::Concern

  # Class level methods injected into ActiveRecord.
  module ClassMethods
Severity: Minor
Found in lib/power_enum/enumerated.rb - About 2 hrs to fix

    Method has_enumerated has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def has_enumerated(part_id, options = {})
          options.assert_valid_keys( :class_name,
                                     :foreign_key,
                                     :on_lookup_failure,
                                     :permit_empty_name,
    Severity: Minor
    Found in lib/power_enum/has_enumerated.rb - About 1 hr to fix

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

          def create_enum(enum_name, options = {}, &block)
            enum_table_name = enum_name.pluralize
            name_column = options[:name_column] || :name
            generate_description = !!options[:description]
            generate_active = !!options[:active]
      Severity: Minor
      Found in lib/power_enum/schema/schema_statements.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_enum has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_enum(enum_class, item)
            case item
            when String, Symbol, Fixnum
              enum_class[item].present?
            when Hash
      Severity: Minor
      Found in lib/testing/rspec.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 define_enum_writer has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def define_enum_writer(attribute_name, class_name, foreign_key, failure_handler, allow_empty_name) #:nodoc:
      Severity: Minor
      Found in lib/power_enum/has_enumerated.rb - About 35 mins to fix

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

              def define(*args, &block)
                options = args.extract_options!
                args.compact!
                args.flatten!
                args.each do |class_name|
        Severity: Minor
        Found in lib/active_record/virtual_enumerations.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

        Severity
        Category
        Status
        Source
        Language