Showing 5 of 5 total issues
Class RealTimeData
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class RealTimeData
include ActiveModel::Serializers::JSON
include ApiResource
attr_accessor :project, :query_filter
Class ProjectAggregation
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class ProjectAggregation < ApplicationRecord
extend DateFilter::Scopes
DEFAULT_CURRENCY = "USD"
Method set_defaults
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
def set_defaults
self.calls_count ||= 0
self.calls_minutes ||= 0
self.calls_price ||= Money.new(0, DEFAULT_CURRENCY)
- 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 fetch!
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def fetch!
twilio_client.usage.records.list(:start_date => date, :end_date => date).each do |record|
case record.category
when "calls"
self.calls_count = record.count
Method validate_each
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate_each(record, attribute, value)
if value || !options[:allow_nil]
begin
parsed_date = Date.parse(value.to_s)
record.errors.add(attribute, :invalid) if options[:on_or_after] && record.public_send(options[:on_or_after]) && parsed_date < record.public_send(options[:on_or_after])
- 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"