dockyard/postgres_ext-serializers

View on GitHub

Showing 6 of 6 total issues

Method _include_relation_in_root has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    def _include_relation_in_root(relation, *args)
      local_options = args.extract_options!
      foreign_key_column = args[0]
      constraining_table = args[1]

Severity: Minor
Found in lib/postgres_ext/serializers/active_model/array_serializer.rb - About 1 day 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 _include_relation_in_root has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def _include_relation_in_root(relation, *args)
      local_options = args.extract_options!
      foreign_key_column = args[0]
      constraining_table = args[1]

Severity: Major
Found in lib/postgres_ext/serializers/active_model/array_serializer.rb - About 4 hrs to fix

    File array_serializer.rb has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module PostgresExt::Serializers::ActiveModel
      module ArraySerializer
        def self.prepended(base)
          base.send :include, IncludeMethods
        end
    Severity: Minor
    Found in lib/postgres_ext/serializers/active_model/array_serializer.rb - About 2 hrs to fix

      Method _results_table_arel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def _results_table_arel(singular_key = nil)
            tables = []
            @_results_tables.each do |key, array|
              json_table = array
                .map {|t| t.project(Arel.star) }
      Severity: Minor
      Found in lib/postgres_ext/serializers/active_model/array_serializer.rb - About 1 hr to fix

        Method build_json has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_json(controller, resource, options)
                serializer_instance = super
                return serializer_instance unless serializer_instance
        
                default_options = controller.send(:default_serializer_options) || {}
        Severity: Minor
        Found in lib/postgres_ext/serializers/active_model/serializer.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 _process_has_many_relation has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _process_has_many_relation(key, embed_key, association_reflection, relation_query, ids_table_arel)
        Severity: Minor
        Found in lib/postgres_ext/serializers/active_model/array_serializer.rb - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language