ForestAdmin/forest-rails

View on GitHub
app/controllers/forest_liana/application_controller.rb

Summary

Maintainability
C
1 day
Test Coverage
F
57%

Method fields_per_model has a Cognitive Complexity of 19 (exceeds 5 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 2 hrs 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 render_csv has a Cognitive Complexity of 15 (exceeds 5 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

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

      There are no issues that match your filters.

      Category
      Status