somleng/somleng-rtd

View on GitHub

Showing 5 of 5 total issues

Class RealTimeData has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class RealTimeData
  include ActiveModel::Serializers::JSON
  include ApiResource

  attr_accessor :project, :query_filter
Severity: Minor
Found in app/models/real_time_data.rb - About 3 hrs to fix

    Class ProjectAggregation has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ProjectAggregation < ApplicationRecord
      extend DateFilter::Scopes
    
      DEFAULT_CURRENCY = "USD"
    
    
    Severity: Minor
    Found in app/models/project_aggregation.rb - About 2 hrs to fix

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

        def set_defaults
          self.calls_count ||= 0
          self.calls_minutes ||= 0
          self.calls_price ||= Money.new(0, DEFAULT_CURRENCY)
      
      
      Severity: Minor
      Found in app/models/project_aggregation.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 fetch! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      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
      Severity: Minor
      Found in app/models/project_aggregation.rb - About 1 hr to fix

        Method validate_each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        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])
        Severity: Minor
        Found in app/validators/date_validator.rb - About 35 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