wawandco/grape-resources

View on GitHub

Showing 3 of 3 total issues

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

      def load_singular_endpoints( clazz, api_instance, methods)
        singular_name = singular_name_for clazz

        api_instance.resource singular_name.to_sym do
          Grape::Resources.get_endpoint_for( clazz, api_instance ) if methods.include?(:get)
Severity: Minor
Found in lib/grape/resources.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 resources_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def resources_for( clazz, methods=[:list, :get, :post, :put, :delete])
        raise Error("To use grape_resources on a given class it should inherit from ActiveRecord::Base.( at least for now buddy ;) )") unless clazz < ActiveRecord::Base
        
        plural_name = clazz.name.pluralize.underscore        
        resources plural_name.to_sym do
Severity: Minor
Found in lib/grape/resources.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 update_endpoint_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def update_endpoint_for(clazz, api_instance)
        singular_name = singular_name_for clazz

        api_instance.put ":id" do
          result = clazz.find_by_id(params[:id])        
Severity: Minor
Found in lib/grape/resources.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