Showing 5 of 5 total issues
Method included
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
Grape::Endpoint.class_eval do
def paginate(collection)
per_page = ApiPagination.config.per_page_param(params) || route_setting(:per_page)
Method pages_from
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def pages_from(collection, options = {})
return pagy_pages_from(collection) if ApiPagination.config.paginator == :pagy && collection.is_a?(Pagy)
{}.tap do |pages|
unless collection.first_page?
- Read upRead up
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 paginate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def paginate(collection)
per_page = ApiPagination.config.per_page_param(params) || route_setting(:per_page)
options = {
:page => ApiPagination.config.page_param(params),
- Read upRead up
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 pagy_pages_from
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def pagy_pages_from(pagy)
{}.tap do |pages|
unless pagy.page == 1
pages[:first] = 1
pages[:prev] = pagy.prev
- Read upRead up
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 _paginate_collection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _paginate_collection(collection, options={})
options[:page] = ApiPagination.config.page_param(params)
options[:per_page] ||= ApiPagination.config.per_page_param(params)
collection, pagy = ApiPagination.paginate(collection, options)
- Read upRead up
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"