ForestAdmin/forest-rails

View on GitHub

Showing 96 of 136 total issues

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

  def init_properties_with_default
    @name_old ||= @name
    @is_virtual ||= false
    @icon ||= nil
    @is_read_only ||= false
Severity: Minor
Found in app/models/forest_liana/model/collection.rb - About 1 hr to fix

    Method validate_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.validate_field(field, action_name)
          raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, nil, "The field attribute must be defined") if !field || field[:field].nil?
          raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, nil, "The field attribute must be a string.") if !field[:field].is_a?(String)
          raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, field[:field], "The description attribute must be a string.") if field[:description] && !field[:description].is_a?(String)
          raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, field[:field], "The enums attribute must be an array.") if field[:enums] && !field[:enums].is_a?(Array)
    Severity: Minor
    Found in app/services/forest_liana/smart_action_field_validator.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def perform(resource)
          @resource = @records = resource
          @tables_associated_to_relations_name =
            ForestLiana::QueryHelper.get_tables_associated_to_relations_name(@resource)
          @records = search_param
    Severity: Minor
    Found in app/services/forest_liana/search_query_builder.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 generate_action_hooks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_action_hooks()
          @collections_sent.each do |collection|
            collection['actions'].each do |action|
              c = get_collection(collection['name'])
              unless c.nil?
    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 extract_carrierwave has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def extract_carrierwave
          return if @params['data']['attributes'].blank?
          return unless @resource.respond_to?(:uploaders)
    
          @params['data']['attributes'].each do |key, value|
    Severity: Minor
    Found in app/deserializers/forest_liana/resource_deserializer.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def perform
          if @params[:groupByFieldName]
            timezone_offset = @params[:timezone].to_i
            resource = optimize_record_loading(@resource, get_resource)
    
    
    Severity: Minor
    Found in app/services/forest_liana/pie_stat_getter.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def perform
          @record = @resource.find(@params[:id])
          associated_records = @resource.find(@params[:id]).send(@association.name)
    
          remove_association = !@with_deletion || @association.macro == :has_and_belongs_to_many
    Severity: Minor
    Found in app/services/forest_liana/has_many_dissociator.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 compute_includes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def compute_includes
          @includes = @association.klass
            .reflect_on_all_associations
            .select do |association|
    
    
    Severity: Minor
    Found in app/services/forest_liana/has_many_getter.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 handle_result has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def handle_result(result, action)
          if result.nil? || !result.is_a?(Array)
            return render status: 500, json: { error: 'Error in smart action load hook: hook must return an array of fields' }
          end
    
    
    Severity: Minor
    Found in app/controllers/forest_liana/actions_controller.rb - About 1 hr to fix

      Method field_names_requested has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def field_names_requested
            return nil unless @params[:fields] && @params[:fields][@collection_name]
      
            associations_for_query = []
      
      
      Severity: Minor
      Found in app/services/forest_liana/resources_getter.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 parse_aggregation_on_previous_interval has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_aggregation_on_previous_interval(node, previous_condition)
            raise_empty_condition_in_filter_error unless node
      
            return parse_previous_interval_condition(node) unless node['aggregator']
      
      
      Severity: Minor
      Found in app/services/forest_liana/filters_parser.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 reject_unauthorized_ip has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def reject_unauthorized_ip
            begin
              ip = request.remote_ip
      
              if !ForestLiana::IpWhitelist.is_ip_whitelist_retrieved || !ForestLiana::IpWhitelist.is_ip_valid(ip)
      Severity: Minor
      Found in app/controllers/forest_liana/base_controller.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(reset_api_map = false)
            if reset_api_map
              ForestLiana.apimap = []
              ForestLiana.models = []
            end
      Severity: Minor
      Found in lib/forest_liana/bootstrapper.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 extract_attributes_serialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def extract_attributes_serialize
            attributes_serialized.each do |attribute, serializer|
              value = @params[:data][:attributes][attribute]
              begin
                if @attributes.has_key?(attribute)
      Severity: Minor
      Found in app/deserializers/forest_liana/resource_deserializer.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

      Avoid deeply nested control flow statements.
      Open

                        if @collection.search_fields.nil? || (association_search &&
                          association_search.include?(column.name))
                          conditions << association_search_condition(resource.table_name,
                            column.name)
                        end
      Severity: Major
      Found in app/services/forest_liana/search_query_builder.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          if !(column.respond_to?(:array) && column.array) && text_type?(column.type)
                            if association_search.include?(column.name)
                              conditions << association_search_condition(resource.table_name,
                                column.name)
                            end
        Severity: Major
        Found in app/services/forest_liana/search_query_builder.rb - About 45 mins to fix

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

              def sort_query
                if @params[:sort]
                  @params[:sort].split(',').each do |field|
                    order_detected = detect_sort_order(field)
                    order = order_detected.upcase
          Severity: Minor
          Found in app/services/forest_liana/search_query_builder.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 fetch_model has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_model(model)
                return if model.abstract_class?
                return if ForestLiana.models.include?(model)
                return unless analyze_model?(model)
          
          
          Severity: Minor
          Found in lib/forest_liana/bootstrapper.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 find_model_from_collection_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.find_model_from_collection_name(collection_name, logs = false)
                model_found = nil
                ForestLiana.models.each do |model|
                  if model.abstract_class?
                    model_found = self.find_model_from_abstract_class(model, collection_name)
          Severity: Minor
          Found in app/services/forest_liana/schema_utils.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 detect_match_and_decorate has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def self.detect_match_and_decorate record, index, field_name, value, search_value, match_fields
          Severity: Minor
          Found in app/helpers/forest_liana/decoration_helper.rb - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language