ForestAdmin/forest-rails

View on GitHub

Showing 96 of 136 total issues

Method render_csv has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def render_csv getter, model
      set_headers_file
      set_headers_streaming

      response.status = 200
Severity: Minor
Found in app/controllers/forest_liana/application_controller.rb - About 1 hr to fix

    Method check_integrations_setup has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_integrations_setup
          if stripe_integration?
            if stripe_integration_valid? || stripe_integration_deprecated?
              ForestLiana.integrations[:stripe][:mapping] =
                cast_to_array(ForestLiana.integrations[:stripe][:mapping])
    Severity: Minor
    Found in lib/forest_liana/bootstrapper.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 get_previous_interval_condition has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_previous_interval_condition
          current_previous_interval = nil
          # NOTICE: Leaf condition at root
          unless @filters['aggregator']
            return @filters if @operator_date_parser.has_previous_interval?(@filters['operator'])
    Severity: Minor
    Found in app/services/forest_liana/filters_parser.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 perform has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def perform
          begin
            query = {
              limit: limit,
              starting_after: starting_after,
    Severity: Minor
    Found in app/services/forest_liana/stripe_invoices_getter.rb - About 1 hr to fix

      Method get_serializer_name has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.get_serializer_name(active_record_class)
            if defined?(::Intercom::Conversation) &&
              active_record_class == ::Intercom::Conversation
              "ForestLiana::IntercomConversationSerializer"
            elsif defined?(::Intercom::User) &&
      Severity: Minor
      Found in app/serializers/forest_liana/serializer_factory.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 perform has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def perform
            add_columns
            add_associations
      
            collection.fields.sort_by!.with_index { |k, idx| [k[:field].to_s, idx] }
      Severity: Minor
      Found in app/services/forest_liana/schema_adapter.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 authenticate_user_from_jwt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def authenticate_user_from_jwt
            begin
              if request.headers
                if request.headers['Authorization']
                  token = request.headers['Authorization'].split.second
      Severity: Minor
      Found in app/controllers/forest_liana/application_controller.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 perform has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def perform
            begin
              @apimap = reorder_keys_basic(@apimap)
              sort_array_of_objects(@apimap['data'])
              @apimap['data'].map! do |collection|
      Severity: Minor
      Found in app/services/forest_liana/apimap_sorter.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 add_associations has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_associations
            SchemaUtils.associations(@model).each do |association|
              begin
                if SchemaUtils.polymorphic?(association) &&
                  collection.fields << {
      Severity: Minor
      Found in app/services/forest_liana/schema_adapter.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 perform has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def perform
            begin
              @apimap = reorder_keys_basic(@apimap)
              sort_array_of_objects(@apimap['data'])
              @apimap['data'].map! do |collection|
      Severity: Minor
      Found in app/services/forest_liana/apimap_sorter.rb - About 1 hr to fix

        Method perform has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def perform
              begin
                query = {
                  limit: limit,
                  starting_after: starting_after,
        Severity: Minor
        Found in app/services/forest_liana/stripe_payments_getter.rb - About 1 hr to fix

          Method perform has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def perform(field_name, field_value)
                result = @mixpanel.request(
                  'jql',
                  script: "function main() {
                    return People().filter(function (user) {
          Severity: Minor
          Found in app/services/forest_liana/mixpanel_last_events_getter.rb - About 1 hr to fix

            Method setup_mixpanel_integration has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def setup_mixpanel_integration(collection_name_and_field)
                  collection_name = collection_name_and_field.split('.')[0]
                  model_name = ForestLiana.name_for(collection_name.constantize)
            
                  field_attributes = { is_filterable: false , is_virtual: true, is_sortable: false }
            Severity: Minor
            Found in lib/forest_liana/bootstrapper.rb - About 1 hr to fix

              Method get_date_filter_for_previous_interval has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def get_date_filter_for_previous_interval(operator, value)
                    return nil unless has_previous_interval? operator
              
                    case operator
                    when OPERATOR_TODAY
              Severity: Minor
              Found in app/services/forest_liana/operator_date_interval_parser.rb - About 1 hr to fix

                Method serialize_collection has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def serialize_collection collection
                    collection_serialized = {
                      id: collection['name'],
                      type: 'collections',
                      attributes: {},
                Severity: Minor
                Found in app/serializers/forest_liana/schema_serializer.rb - About 1 hr to fix

                  Method perform has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def perform
                        begin
                          query = {
                            limit: limit,
                            starting_after: starting_after,
                  Severity: Minor
                  Found in app/services/forest_liana/stripe_subscriptions_getter.rb - About 1 hr to fix

                    Method check_integrations_setup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def check_integrations_setup
                          if stripe_integration?
                            if stripe_integration_valid? || stripe_integration_deprecated?
                              ForestLiana.integrations[:stripe][:mapping] =
                                cast_to_array(ForestLiana.integrations[:stripe][:mapping])
                    Severity: Minor
                    Found in lib/forest_liana/bootstrapper.rb - About 1 hr to fix

                      Method fields_per_model has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def fields_per_model(params_fields, model)
                            if params_fields
                              if Rails::VERSION::MAJOR > 4
                                params_fields_hash = params_fields.to_unsafe_h
                              else
                      Severity: Minor
                      Found in app/controllers/forest_liana/application_controller.rb - About 1 hr to fix

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

                            def self.get_serializer_name(active_record_class)
                              if defined?(::Intercom::Conversation) &&
                                active_record_class == ::Intercom::Conversation
                                "ForestLiana::IntercomConversationSerializer"
                              elsif defined?(::Intercom::User) &&
                        Severity: Minor
                        Found in app/serializers/forest_liana/serializer_factory.rb - About 1 hr to fix

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

                              def self.get_ids_from_request(params, user)
                                attributes = params.dig('data', 'attributes')
                                has_body_attributes = attributes != nil
                                is_select_all_records_query = has_body_attributes && attributes[:all_records] == true
                          
                          
                          Severity: Minor
                          Found in app/services/forest_liana/resources_getter.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language