ForestAdmin/forest-rails

View on GitHub

Showing 96 of 136 total issues

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

    def force_utf8_attributes_encoding(model)
      # NOTICE: Declare all strings are encoded in utf-8
      if model['attributes']
        model['attributes'].each do |name, value|
          if value.respond_to?(:force_encoding)
Severity: Minor
Found in app/controllers/forest_liana/application_controller.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 configure_forest_cors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def configure_forest_cors
      begin
        rack_cors_class = Rack::Cors
        rack_cors_class = 'Rack::Cors' if Rails::VERSION::MAJOR < 5
        null_regex = Regexp.new(/\Anull\z/)
Severity: Minor
Found in lib/forest_liana/engine.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def perform
      return if @params[:aggregator].blank?
      resource = optimize_record_loading(@resource, get_resource)

      filters = ForestLiana::ScopeManager.append_scope_for_user(@params[:filter], @user, @resource.name, @params['contextVariables'])
Severity: Minor
Found in app/services/forest_liana/value_stat_getter.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 perform has a Cognitive Complexity of 7 (exceeds 5 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 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_field_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_field_name(field)
      if is_belongs_to(field)
        current_resource = @resource.reflect_on_association(field.split(':').first.to_sym)&.klass
        raise ForestLiana::Errors::HTTP422Error.new("Field '#{field}' not found") unless current_resource

Severity: Minor
Found in app/services/forest_liana/filters_parser.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 get_date_filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_date_filter(operator, value)
      return nil unless is_date_operator? operator

      filter = case operator
        when OPERATOR_FUTURE
Severity: Minor
Found in app/services/forest_liana/operator_date_interval_parser.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 perform has a Cognitive Complexity of 7 (exceeds 5 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 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 perform has a Cognitive Complexity of 7 (exceeds 5 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 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 ensure_valid_condition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def ensure_valid_condition(condition)
      raise_empty_condition_in_filter_error if condition.empty?
      raise ForestLiana::Errors::HTTP422Error.new('Condition cannot be a raw value') unless condition.is_a?(Hash)
      unless condition['field'].is_a?(String) and condition['operator'].is_a?(String)
        raise ForestLiana::Errors::HTTP422Error.new('Invalid condition format')
Severity: Minor
Found in app/services/forest_liana/filters_parser.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 process_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.process_response(response, expected = {})
      statusCode = expected[:statusCode] || 200
      body = expected[:body] || true

      if (response.code.to_i != statusCode.to_i)
Severity: Minor
Found in app/services/forest_liana/oidc_dynamic_client_registrator.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 order has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def order
      order = 'DESC'

      # NOTICE: The generated alias for a count is "count_all", for a sum the
      #         alias looks like "sum_#{aggregateFieldName}"
Severity: Minor
Found in app/services/forest_liana/pie_stat_getter.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 get_ids_from_request has a Cognitive Complexity of 6 (exceeds 5 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 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 get_date_filter_for_previous_interval has a Cognitive Complexity of 6 (exceeds 5 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 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 detect_reference has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def detect_reference(param)
      ref, field = param.split('.')

      if ref && field
        association = @resource.reflect_on_all_associations
Severity: Minor
Found in app/services/forest_liana/search_query_builder.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_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_query
      @records = get_resource

      if @segment && @segment.scope
        @records = @records.send(@segment.scope)
Severity: Minor
Found in app/services/forest_liana/resources_getter.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 is_standard_body_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.is_standard_body_error(response)
      result = false
      begin
        jsonbody

Severity: Minor
Found in app/services/forest_liana/oidc_dynamic_client_registrator.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