aglushkov/serega

View on GitHub

Showing 12 of 28 total issues

Method inherited has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def inherited(subclass)
      config_class = Class.new(self::SeregaConfig)
      config_class.serializer_class = subclass
      subclass.const_set(:SeregaConfig, config_class)
      subclass.instance_variable_set(:@config, subclass::SeregaConfig.new(config.opts))
Severity: Minor
Found in lib/serega.rb - About 1 hr to fix

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

              def append_many(preloads, plan)
                plan.points.each do |point|
                  current_preloads = point.attribute.preloads
                  next unless current_preloads
    
    
    Severity: Minor
    Found in lib/serega/plugins/preloads/lib/preloads_constructor.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def validate(serializer_class, fields)
              fields.each do |name, nested_fields|
                attribute = serializer_class && serializer_class.attributes[name]
    
                # Save error when no attribute with checked name exists
    Severity: Minor
    Found in lib/serega/validations/initiate/check_modifiers.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 check_proc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

              def check_proc(value)
                raise SeregaError, value_error unless value.is_a?(Proc)
    
                params = value.parameters
    
    
    Severity: Minor
    Found in lib/serega/validations/attribute/check_opt_value.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

              def call(opts)
                return unless opts.key?(:preload_path)
    
                value = opts[:preload_path]
                raise SeregaError, "Invalid option :preload_path => #{value.inspect}. Can be provided only when :preload option provided" unless opts[:preload]
    Severity: Minor
    Found in lib/serega/plugins/preloads/validations/check_opt_preload_path.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 attributes_points has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def attributes_points(modifiers)
            only = modifiers[:only] || FROZEN_EMPTY_HASH
            except = modifiers[:except] || FROZEN_EMPTY_HASH
            with = modifiers[:with] || FROZEN_EMPTY_HASH
            points = []
    Severity: Minor
    Found in lib/serega/plan.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 prepare_batch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def prepare_batch
              batch = init_opts[:batch]
              return unless batch
    
              # take loader
    Severity: Minor
    Found in lib/serega/plugins/batch/lib/modules/attribute_normalizer.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 add_metadata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def add_metadata(object, context, hash)
              self.class.meta_attributes.each_value do |meta_attribute|
                metadata = meta_attribute_value(object, context, meta_attribute)
                next unless metadata
    
    
    Severity: Minor
    Found in lib/serega/plugins/metadata/metadata.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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

              def parse(fields)
                res = {}
                attribute = +""
                char = +""
                path_stack = nil
    Severity: Minor
    Found in lib/serega/plugins/string_modifiers/parse_string_modifiers.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 visible? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def visible?(modifiers)
            except = modifiers[:except] || FROZEN_EMPTY_HASH
            only = modifiers[:only] || FROZEN_EMPTY_HASH
            with = modifiers[:with] || FROZEN_EMPTY_HASH
    
    
    Severity: Minor
    Found in lib/serega/attribute.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 preload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def preload(object, preloads)
                return object if object.nil? || (object.is_a?(Array) && object.empty?) || preloads.empty?
    
                preload_handler = handlers.find { |handler| handler.fit?(object) }
                raise SeregaError, "Can't preload #{preloads.inspect} to #{object.inspect}" unless preload_handler
    Severity: Minor
    Found in lib/serega/plugins/activerecord_preloads/lib/preloader.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 plugin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def plugin(name, **opts)
          raise SeregaError, "This plugin is already loaded" if plugin_used?(name)
    
          plugin = SeregaPlugins.find_plugin(name)
    
    
    Severity: Minor
    Found in lib/serega.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