aglushkov/serega

View on GitHub

Showing 39 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module SeregaPlugins
        module If
          #
          # Validator for attribute :if_value option
          #
    Severity: Major
    Found in lib/serega/plugins/if/validations/check_opt_if_value.rb and 1 other location - About 1 hr to fix
    lib/serega/plugins/if/validations/check_opt_unless_value.rb on lines 4..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 66.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module SeregaPlugins
        module If
          #
          # Validator for attribute :unless_value option
          #
    Severity: Major
    Found in lib/serega/plugins/if/validations/check_opt_unless_value.rb and 1 other location - About 1 hr to fix
    lib/serega/plugins/if/validations/check_opt_if_value.rb on lines 4..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 66.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        module SeregaPlugins
          module If
            #
            # Validator for attribute :unless option
            #
      Severity: Major
      Found in lib/serega/plugins/if/validations/check_opt_unless.rb and 1 other location - About 1 hr to fix
      lib/serega/plugins/if/validations/check_opt_if.rb on lines 4..41

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 55.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        module SeregaPlugins
          module If
            #
            # Validator for attribute :if option
            #
      Severity: Major
      Found in lib/serega/plugins/if/validations/check_opt_if.rb and 1 other location - About 1 hr to fix
      lib/serega/plugins/if/validations/check_opt_unless.rb on lines 4..41

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 55.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

              def self.before_load_plugin(serializer_class, **opts)
                allowed_keys = %i[formatters]
                opts.each_key do |key|
                  next if allowed_keys.include?(key)
        
        
        Severity: Minor
        Found in lib/serega/plugins/formatters/formatters.rb and 1 other location - About 45 mins to fix
        lib/serega/plugins/context_metadata/context_metadata.rb on lines 37..48

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

              def self.before_load_plugin(serializer_class, **opts)
                allowed_keys = %i[context_metadata_key]
                opts.each_key do |key|
                  next if allowed_keys.include?(key)
        
        
        Severity: Minor
        Found in lib/serega/plugins/context_metadata/context_metadata.rb and 1 other location - About 45 mins to fix
        lib/serega/plugins/formatters/formatters.rb on lines 58..69

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 39.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        gemfile(true, quiet: true) do
          source "https://rubygems.org"
          git_source(:github) { |repo| "https://github.com/#{repo}.git" }
        
          gem "serega", path: File.join(File.dirname(__FILE__), "..")
        Severity: Minor
        Found in examples/batch_loader.rb and 1 other location - About 25 mins to fix
        examples/preloads.rb on lines 5..11

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 31.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        gemfile(true, quiet: true) do
          source "https://rubygems.org"
          git_source(:github) { |repo| "https://github.com/#{repo}.git" }
        
          gem "serega", path: File.join(File.dirname(__FILE__), "..")
        Severity: Minor
        Found in examples/preloads.rb and 1 other location - About 25 mins to fix
        examples/batch_loader.rb on lines 5..11

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 31.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Severity
        Category
        Status
        Source
        Language