reevoo/sapience-rb

View on GitHub

Showing 33 of 1,401 total issues

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

Method call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def call(log, _logger) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
        # Date & time
        message = time_format.nil? ? "" : "#{format_time(log.time)} "

        # Log level and process info
Severity: Minor
Found in lib/sapience/formatters/default.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 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 log_with_level has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def log_with_level(level, message = nil, payload = nil, exception = nil, &block)
Severity: Minor
Found in lib/sapience/log_methods.rb - About 35 mins to fix

    Method log_with_exception has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def log_with_exception(level, message = nil, payload = nil, exception = nil, &block)
    Severity: Minor
    Found in lib/sapience/log_methods.rb - About 35 mins to fix

      Method log_internal has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def log_internal(level, index, message = nil, payload = nil, exception = nil)
      Severity: Minor
      Found in lib/sapience/base.rb - About 35 mins to fix

        Method constantize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.constantize(class_name)
            return class_name unless class_name.is_a?(String)
            if RUBY_VERSION.to_i >= 2
              Object.const_get(class_name)
            else
        Severity: Minor
        Found in lib/sapience/sapience.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

        Method included has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        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")
        Severity: Minor
        Found in lib/sapience/extensions/active_record/model_metrics.rb - About 25 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 namify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.namify(appname, sep = "_")
            return unless appname.is_a?(String)
            return if appname.empty?
        
            # Turn unwanted chars into the separator
        Severity: Minor
        Found in lib/sapience/sapience.rb - About 25 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 duration_to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def duration_to_s
              return unless duration
              format((duration < 10.0 ? "%.3fms" : "%.1fms"), duration)
            end
        Severity: Minor
        Found in lib/sapience/log.rb - About 25 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 backtrace_to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def backtrace_to_s
              trace = ""
              each_exception do |exception, i|
                if i == 0
                  trace += (exception.backtrace || []).join("\n")
        Severity: Minor
        Found in lib/sapience/log.rb - About 25 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 record has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def record(event) # rubocop:disable AbcSize
                  return unless record?
        
                  payload = event.payload
                  method  = payload[:method].downcase
        Severity: Minor
        Found in lib/sapience/extensions/action_controller/notifications.rb - About 25 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 yaml_safe_load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        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 - About 25 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