ForestAdmin/forest-rails

View on GitHub

Showing 121 of 136 total issues

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

    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

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

        def payments
          getter = StripePaymentsGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 2 other locations - About 40 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 64..74
    app/controllers/forest_liana/stripe_controller.rb on lines 88..98

    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 38.

    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 3 locations. Consider refactoring.
    Open

        def invoices
          getter = StripeInvoicesGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 2 other locations - About 40 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 4..14
    app/controllers/forest_liana/stripe_controller.rb on lines 88..98

    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 38.

    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 3 locations. Consider refactoring.
    Open

        def subscriptions
          getter = StripeSubscriptionsGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 2 other locations - About 40 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 4..14
    app/controllers/forest_liana/stripe_controller.rb on lines 64..74

    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 38.

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

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

        def payment
          getter = StripePaymentGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 4 other locations - About 35 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 52..62
    app/controllers/forest_liana/stripe_controller.rb on lines 76..86
    app/controllers/forest_liana/stripe_controller.rb on lines 100..110
    app/controllers/forest_liana/stripe_controller.rb on lines 125..135

    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 35.

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

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

        def invoice
          getter = StripeInvoiceGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 4 other locations - About 35 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 16..26
    app/controllers/forest_liana/stripe_controller.rb on lines 52..62
    app/controllers/forest_liana/stripe_controller.rb on lines 100..110
    app/controllers/forest_liana/stripe_controller.rb on lines 125..135

    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 35.

    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 5 locations. Consider refactoring.
    Open

        def bank_account
          getter = StripeSourceGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 4 other locations - About 35 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 16..26
    app/controllers/forest_liana/stripe_controller.rb on lines 52..62
    app/controllers/forest_liana/stripe_controller.rb on lines 76..86
    app/controllers/forest_liana/stripe_controller.rb on lines 100..110

    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 35.

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

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

        def card
          getter = StripeSourceGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 4 other locations - About 35 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 16..26
    app/controllers/forest_liana/stripe_controller.rb on lines 76..86
    app/controllers/forest_liana/stripe_controller.rb on lines 100..110
    app/controllers/forest_liana/stripe_controller.rb on lines 125..135

    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 35.

    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 5 locations. Consider refactoring.
    Open

        def subscription
          getter = StripeSubscriptionGetter.new(params, request.headers['Stripe-Secret-Key'],
            request.headers['Stripe-Reference'])
          getter.perform
    
    
    Severity: Major
    Found in app/controllers/forest_liana/stripe_controller.rb and 4 other locations - About 35 mins to fix
    app/controllers/forest_liana/stripe_controller.rb on lines 16..26
    app/controllers/forest_liana/stripe_controller.rb on lines 52..62
    app/controllers/forest_liana/stripe_controller.rb on lines 76..86
    app/controllers/forest_liana/stripe_controller.rb on lines 125..135

    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 35.

    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

    Severity
    Category
    Status
    Source
    Language