Apipie/apipie-rails

View on GitHub
lib/apipie/application.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Application has 44 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Application
    # we need engine just for serving static assets
    class Engine < Rails::Engine
      initializer "static assets", :before => :build_middleware_stack do |app|
        app.middleware.use ::Apipie::StaticDispatcher, "#{root}/app/public"
Severity: Minor
Found in lib/apipie/application.rb - About 6 hrs to fix

    File application.rb has 359 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'apipie/static_dispatcher'
    require 'apipie/routes_formatter'
    require 'yaml'
    require 'digest/sha1'
    require 'json'
    Severity: Minor
    Found in lib/apipie/application.rb - About 4 hrs to fix

      Method get_resource_description has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_resource_description(resource, version = nil)
            if resource.is_a?(String)
              crumbs = resource.split('#')
              if crumbs.size == 2
                version = crumbs.first
      Severity: Minor
      Found in lib/apipie/application.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_resource_id has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_resource_id(klass)
            if klass.class == String
              klass
            elsif @controller_to_resource_id.key?(klass)
              @controller_to_resource_id[klass]
      Severity: Minor
      Found in lib/apipie/application.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 valid_search_args? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def valid_search_args?(version, resource_id, method_name)
            return false unless self.resource_descriptions.key?(version)
            if resource_id
              return false unless self.resource_descriptions[version].key?(resource_id)
              if method_name
      Severity: Minor
      Found in lib/apipie/application.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 rails_routes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def rails_routes(route_set = nil, base_url = "")
            return @_rails_routes if route_set.nil? && @_rails_routes
      
            route_set ||= Rails.application.routes
            # ensure routes are loaded
      Severity: Minor
      Found in lib/apipie/application.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 to_json has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_json(version, resource_id, method_name, lang)
      
            return unless valid_search_args?(version, resource_id, method_name)
      
            _resources = if resource_id.blank?
      Severity: Minor
      Found in lib/apipie/application.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 to_swagger_json has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def to_swagger_json(version, resource_id, method_name, language, clear_warnings = false)
      Severity: Minor
      Found in lib/apipie/application.rb - About 35 mins to fix

        Method json_schema_for_method_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def json_schema_for_method_response(version, controller_name, method_name, return_code, allow_nulls)
        Severity: Minor
        Found in lib/apipie/application.rb - About 35 mins to fix

          Method define_method_description has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def define_method_description(controller, method_name, dsl_data)
                return if ignored?(controller, method_name)
                ret_method_description = nil
          
                versions = dsl_data[:api_versions] || []
          Severity: Minor
          Found in lib/apipie/application.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 define_resource_description has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def define_resource_description(controller, version, dsl_data = nil)
                return if ignored?(controller)
          
                resource_id = get_resource_id(controller)
                resource_description = @resource_descriptions[version][resource_id]
          Severity: Minor
          Found in lib/apipie/application.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

          There are no issues that match your filters.

          Category
          Status