reevoo/sapience-rb

View on GitHub

Showing 1,401 of 1,401 total issues

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

    def camelize(uppercase_first_letter = true)
      string = to_s
      string = if uppercase_first_letter
                 string.sub(/^[a-z\d]*/) { $&.capitalize }
               else
Severity: Minor
Found in lib/sapience/core_ext/symbol.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. [11/10]
Open

      def yaml_safe_load(yaml_code, filename)
        if YAML.respond_to?(:safe_load) # Ruby 2.1+
          if defined?(SafeYAML) && SafeYAML.respond_to?(:load)
            SafeYAML.load(yaml_code, filename,
              whitelisted_tags: %w(!ruby/regexp),
Severity: Minor
Found in lib/sapience/config_loader.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. [11/10]
Open

      def capture_type(data, payload)
        return false unless valid?
        configure_sentry

        options = if payload.present?

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. [11/10]
Open

      def event(title, text = "", opts = {})
        return false unless valid?
        fail ArgumentError "Title must be provided" unless title
        opts ||= {}

Severity: Minor
Found in lib/sapience/metrics/datadog.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 call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
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 - 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

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

namespace :coverage do
  task :merge do
    hide_coverage_config
    require "json"
    require "simplecov/version"
Severity: Minor
Found in lib/tasks/coverage.rake 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 to_h has 43 lines of code (exceeds 25 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 1 hr to fix

    Method log has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def log(log, message = nil, progname = nil, &block)
          # Compatibility with ::Logger
          return add(log, message, progname, &block) unless log.is_a?(Sapience::Log)
          if @@appender_thread
            @@appender_thread << lambda do
    Severity: Minor
    Found in lib/sapience/logger.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 capture_type has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def capture_type(data, payload)
            return false unless valid?
            configure_sentry
    
            options = if payload.present?
    Severity: Minor
    Found in lib/sapience/error_handler/sentry.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 log_internal has 39 lines of code (exceeds 25 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 1 hr to fix

      Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(klass, level = nil, filter = nil, log_hooks = [])
            # Support filtering all messages to this logger using a Regular Expression
            # or Proc
            fail ArgumentError, ":filter must be a Regexp or Proc" unless filter.nil? || filter.is_a?(Regexp) || filter.is_a?(Proc)
      
      
      Severity: Minor
      Found in lib/sapience/base.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 payload has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def payload # rubocop:disable AbcSize
            return self[:payload] unless self[:payload].is_a?(Hash) && self[:payload][:params].is_a?(Hash)
            @payload ||= nil
            return @payload unless @payload.nil?
      
      
      Severity: Minor
      Found in lib/sapience/log.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

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

      Gem::Specification.new do |spec|
        spec.name          = "sapience"
        spec.version       = Sapience::VERSION
        spec.authors       = ["Mikael Henriksson", "Alex Malkov"]
        spec.email         = ["mika@reevoo.com", "alex.malkov@reevoo.com"]
      Severity: Minor
      Found in sapience.gemspec 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 flush has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.flush # rubocop:disable AbcSize
            return unless appender_thread
            appender_thread << lambda do
              Sapience.appenders.each do |appender|
                next unless appender.valid?
      Severity: Minor
      Found in lib/sapience/logger.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 parse_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_options(options)
              @time_format     = options.key?(:time_format) ? options.delete(:time_format) : default_time_format
              @log_host        = options.key?(:log_host) ? options.delete(:log_host) : true
              @log_application = options.key?(:log_application) ? options.delete(:log_application) : true
              @exclude_fields  = options.key?(:exclude_fields) ? options.delete(:exclude_fields).map(&:to_sym) : {}
      Severity: Minor
      Found in lib/sapience/formatters/base.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 close has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.close
            return unless appender_thread
            appender_thread << lambda do
              Sapience.appenders.each do |appender|
                next unless appender.valid?
      Severity: Minor
      Found in lib/sapience/logger.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 file_name_and_line has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def file_name_and_line(short_name = false) # rubocop:disable CyclomaticComplexity
            return unless backtrace || (exception && exception.backtrace) # rubocop: disable Style/SafeNavigation
            stack = backtrace || exception.backtrace
            extract_file_and_line(stack, short_name) if stack && !stack.empty?
          end
      Severity: Minor
      Found in lib/sapience/log.rb - About 55 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 extract_formatter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def extract_formatter(formatter, &block)
            if formatter.is_a?(Symbol) || formatter.is_a?(String)
              Sapience.constantize_symbol(formatter, "Sapience::Formatters").new
            elsif formatter.is_a?(Hash) && !formatter.empty?
              fmt, options = formatter.first
      Severity: Minor
      Found in lib/sapience/subscriber.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 timing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def timing(metric, duration = 0, options = {})
              if block_given?
                start = Time.now
                yield
                return false unless valid?
      Severity: Minor
      Found in lib/sapience/metrics/datadog.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 event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def event(title, text = "", opts = {})
              return false unless valid?
              fail ArgumentError "Title must be provided" unless title
              opts ||= {}
      
      
      Severity: Minor
      Found in lib/sapience/metrics/datadog.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

      Severity
      Category
      Status
      Source
      Language