reevoo/sapience-rb

View on GitHub

Showing 1,401 of 1,401 total issues

Module has too many lines. [242/100]
Open

module Sapience
  UnknownClass   = Class.new(NameError)
  AppNameMissing = Class.new(NameError)
  TestException  = Class.new(StandardError)
  UnkownLogLevel = Class.new(StandardError)
Severity: Minor
Found in lib/sapience/sapience.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [149/100]
Open

module Sapience
  # Log Struct
  #
  #   Structure for holding all log entries. We're using a struct because we want it to be fast and lightweight.
  #
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Block has too many lines. [146/25]
Open

  Log = Struct.new(:level, :thread_name, :name, :message, :payload, :time, :duration, :tags, :level_index, :exception, :metric, :backtrace, :metric_amount) do
    MAX_EXCEPTIONS_TO_UNWRAP = 5
    MILLISECONDS_IN_SECOND =   1_000
    MILLISECONDS_IN_MINUTE = 60_000
    MILLISECONDS_IN_HOUR = 3_600_000
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method has too many lines. [64/10]
Open

    def measure_internal(level, index, message, params)
      params.dup
      start     = Time.now
      exception = nil
      begin
Severity: Minor
Found in lib/sapience/base.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [43/10]
Open

    def to_h(host = Sapience.config.host, app_name = Sapience.app_name, environment = Sapience.environment) # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity, LineLength
      # Header
      h = {
        name:        name,
        pid:         $PROCESS_ID,
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [39/10]
Open

    def log_internal(level, index, message = nil, payload = nil, exception = nil)
      # Exception being logged?
      if exception.nil? && payload.nil? && message.respond_to?(:backtrace) && message.respond_to?(:message)
        exception = message
        message   = nil
Severity: Minor
Found in lib/sapience/base.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method measure_internal has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def measure_internal(level, index, message, params)
      params.dup
      start     = Time.now
      exception = nil
      begin
Severity: Minor
Found in lib/sapience/base.rb - About 4 hrs 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 log_internal has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def log_internal(level, index, message = nil, payload = nil, exception = nil)
      # Exception being logged?
      if exception.nil? && payload.nil? && message.respond_to?(:backtrace) && message.respond_to?(:message)
        exception = message
        message   = nil
Severity: Minor
Found in lib/sapience/base.rb - About 4 hrs 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_h has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def to_h(host = Sapience.config.host, app_name = Sapience.app_name, environment = Sapience.environment) # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity, LineLength
      # Header
      h = {
        name:        name,
        pid:         $PROCESS_ID,
Severity: Minor
Found in lib/sapience/log.rb - About 4 hrs 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 has too many lines. [22/10]
Open

        def record(event) # rubocop:disable AbcSize
          return unless record?

          payload = event.payload
          method  = payload[:method].downcase

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [22/10]
Open

      def call(log, _logger) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
        colors      = Sapience::AnsiColors
        level_color = colors::LEVEL_MAP[log.level]


Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [21/10]
Open

        def self.included(base) # rubocop:disable AbcSize
          base.extend(ClassMethods)
          base.class_eval do
            const_set(:SAPIENCE_MODEL_CREATE_METRICS_KEY,  "model.#{tableized_name}.create")
            const_set(:SAPIENCE_MODEL_UPDATE_METRICS_KEY,  "model.#{tableized_name}.update")

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [20/10]
Open

    def duration_human # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
      return nil unless duration
      days, ms    = duration.divmod(MILLISECONDS_IN_DAY)
      hours, ms   = ms.divmod(MILLISECONDS_IN_HOUR)
      minutes, ms = ms.divmod(MILLISECONDS_IN_MINUTE)
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [19/10]
Open

          def call!(env)
            @env = env
            before
            error = catch(:error) do
              begin

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [19/10]
Open

    def initialize(options = {}) # rubocop:disable AbcSize
      fail ArgumentError, "options need to be a hash #{options.inspect}" unless options.is_a?(Hash)
      @options = DEFAULT.merge(options.dup.deep_symbolize_keyz!)
      @options[:log_executor] &&= @options[:log_executor].to_sym
      validate_log_executor!(@options[:log_executor])
Severity: Minor
Found in lib/sapience/configuration.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [18/10]
Open

        def record(event) # rubocop:disable AbcSize
          return unless record?

          payload  = event.payload
          endpoint = payload[:endpoint]

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method measure_internal has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def measure_internal(level, index, message, params)
      params.dup
      start     = Time.now
      exception = nil
      begin
Severity: Major
Found in lib/sapience/base.rb - About 2 hrs to fix

    Method duration_human has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def duration_human # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
          return nil unless duration
          days, ms    = duration.divmod(MILLISECONDS_IN_DAY)
          hours, ms   = ms.divmod(MILLISECONDS_IN_HOUR)
          minutes, ms = ms.divmod(MILLISECONDS_IN_MINUTE)
    Severity: Minor
    Found in lib/sapience/log.rb - About 2 hrs 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 has too many lines. [16/10]
    Open

              def parameters # rubocop:disable AbcSize
                {
                  method: request.request_method,
                  request_path: @env["REQUEST_URI"] || @env["PATH_INFO"],
                  status: @status,

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [16/10]
    Open

        def each_exception # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
          # With thanks to https://github.com/bugsnag/bugsnag-ruby/blob/6348306e44323eee347896843d16c690cd7c4362/lib/bugsnag/notification.rb#L81
          depth      = 0
          exceptions = []
          ex         = exception
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Severity
    Category
    Status
    Source
    Language