aglushkov/serega

View on GitHub

Showing 19 of 39 total issues

Class SeregaAttributeNormalizer has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class SeregaAttributeNormalizer
    #
    # AttributeNormalizer instance methods
    #
    module AttributeNormalizerInstanceMethods
Severity: Minor
Found in lib/serega/attribute_normalizer.rb - About 2 hrs to fix

    Method call has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

            def call(object, max_count:)
              # Procs (but not lambdas) can accept all provided parameters
              parameters = object.is_a?(Proc) ? object.parameters : object.method(:call).parameters
              return 1 if parameters[0] == NO_NAMED_REST_PARAM
              return max_count if object.is_a?(Proc) && !object.lambda?
    Severity: Minor
    Found in lib/serega/utils/params_count.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

    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 after_load_plugin has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.after_load_plugin(serializer_class, **opts)
              serializer_class::SeregaConfig.include(ConfigInstanceMethods)
      
              batch_loaders_class = Class.new(SeregaBatchLoaders)
              batch_loaders_class.serializer_class = serializer_class
      Severity: Minor
      Found in lib/serega/plugins/batch/batch.rb - About 1 hr to fix

        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 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 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 check_if_unless has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def check_if_unless(obj, ctx, opt_if_name, opt_unless_name)
                  opt_if = attribute.opt_if[opt_if_name]
                  opt_unless = attribute.opt_if[opt_unless_name]
                  return true if opt_if.nil? && opt_unless.nil?
        
        
        Severity: Minor
        Found in lib/serega/plugins/if/if.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 define has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def define(loader_name, callable = nil, &block)
                  if (!callable && !block) || (callable && block)
                    raise SeregaError, "Batch loader can be specified with one of arguments - callable value or &block"
                  end
        
        
        Severity: Minor
        Found in lib/serega/plugins/batch/lib/batch_config.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def self.call(callable, callable_description)
                  parameters = callable.is_a?(Proc) ? callable.parameters : callable.method(:call).parameters
        
                  parameters.each do |parameter|
                    next unless parameter[0] == :keyreq
        Severity: Minor
        Found in lib/serega/validations/utils/check_extra_keyword_arg.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 prepare_preloads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def prepare_preloads
                  opts = init_opts
                  preloads_provided = opts.key?(:preload)
                  preloads =
                    if preloads_provided
        Severity: Minor
        Found in lib/serega/plugins/preloads/lib/modules/attribute_normalizer.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 after_load_plugin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.after_load_plugin(serializer_class, **opts)
                serializer_class::SeregaConfig.include(ConfigInstanceMethods)
        
                batch_loaders_class = Class.new(SeregaBatchLoaders)
                batch_loaders_class.serializer_class = serializer_class
        Severity: Minor
        Found in lib/serega/plugins/batch/batch.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 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 transform= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def transform=(value)
                  raise SeregaError, "Transform value must respond to #call" unless value.respond_to?(:call)
        
                  params = value.is_a?(Proc) ? value.parameters : value.method(:call).parameters
                  if params.count != 1 || !params.all? { |param| (param[0] == :req) || (param[0] == :opt) }
        Severity: Minor
        Found in lib/serega/plugins/camel_case/camel_case.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 check_usage_with_other_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def check_usage_with_other_options(path, opts)
                    return unless path
        
                    preload = opts[:preload]
                    raise SeregaError, "Invalid option preload_path: #{path.inspect}. Can be provided only when :preload option provided" unless preload
        Severity: Minor
        Found in lib/serega/plugins/preloads/validations/check_opt_preload_path.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