le0pard/mongodb_logger

View on GitHub

Showing 64 of 86 total issues

Consider simplifying this complex logical expression.
Open

    if (typeof document !== "undefined" && !("classList" in document.createElement("a"))) {

    (function (view) {

    "use strict";
Severity: Major
Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 40 mins to fix

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

        def initialize(path = nil, level = DEBUG)
          set_root_and_env
          begin
            path ||= File.join(app_root, "log/#{app_env}.log")
            @level = level
    Severity: Minor
    Found in lib/mongodb_logger/logger.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(options = {})
            @configuration = options
            if @configuration[:url]
              uri = URI.parse(@configuration[:url])
              @configuration[:database] = uri.path.gsub(/^\//, '')
    Severity: Minor
    Found in lib/mongodb_logger/adapters/moped.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 record_serializer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def record_serializer(rec, nice = true)
          [:messages, :params].each do |key|
            if msgs = rec[key]
              msgs.each do |i, j|
                msgs[i] = (true == nice ? nice_serialize_object(j) : j.inspect)
    Severity: Minor
    Found in lib/mongodb_logger/logger.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 enable_mongodb_logger has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def enable_mongodb_logger
          return yield unless Rails.logger.respond_to?(:mongoize)
          f_session = (request.respond_to?(:session) ? request.session : session)
          Rails.logger.mongoize({
            method:         request.method,
    Severity: Minor
    Found in lib/mongodb_logger.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(options = {})
            @authenticated = false
            @configuration = options
            if @configuration[:url]
              uri = URI.parse(@configuration[:url])
    Severity: Minor
    Found in lib/mongodb_logger/adapters/mongo.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 read_config_from_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_config_from_file(config_file)
          if File.file? config_file
            config = ::YAML.load(ERB.new(File.new(config_file).read).result)[app_env]
            config = config['mongodb_logger'] if config && config.has_key?('mongodb_logger')
            return config unless config.blank?
    Severity: Minor
    Found in lib/mongodb_logger/logger.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

    Avoid too many return statements within this function.
    Open

        else                      { return y }
    Severity: Major
    Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          else if (y < 1 && y > 0)    { return y.toFixed(2) }
      Severity: Major
      Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            else if (y < 1 && y > 0)  { return y.toFixed(2) }
        Severity: Major
        Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              else if (y == 0)          { return '' }
          Severity: Major
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                else                        { return y }
            Severity: Major
            Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  else if (y >= 1024)         { return y / 1024 + "K" }
              Severity: Major
              Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    else if (y == 0)            { return '' }
                Severity: Major
                Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 30 mins to fix

                  Method set_params_to_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def set_params_to_methods
                          @params.each do |k,v|
                            self.send("#{k}=", v) if self.respond_to?(k) && v && !v.blank?
                          end unless @params.blank?
                        end
                  Severity: Minor
                  Found in lib/mongodb_logger/server/model/base.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 configure has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def configure
                        @db_configuration = {
                            host: 'localhost',
                            port: 27017,
                            ssl: false,
                  Severity: Minor
                  Found in lib/mongodb_logger/logger.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 create_logger has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def create_logger(config)
                        path = config.paths['log'].first
                        level = RailsLogger.const_get(config.log_level.to_s.upcase)
                        logger = MongodbLogger::Logger.new(path, level)
                        # decorating with TaggedLogging
                  Severity: Minor
                  Found in lib/mongodb_logger/initializer_mixin.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 partial has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def partial(template, *args)
                      template_array = template.to_s.split('/')
                      template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
                      options = args.last.is_a?(Hash) ? args.pop : {}
                      options.merge!(:layout => false)
                  Severity: Minor
                  Found in lib/mongodb_logger/server/helpers/partials.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 render_progress has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def render_progress(percent)
                          @progress = percent
                          print "["
                  
                          print "*" * [(percent/10).to_i, 10].min
                  Severity: Minor
                  Found in lib/mongodb_logger/utils/progressbar.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 ensure_write_to_mongodb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def ensure_write_to_mongodb
                        @insert_block.call
                      rescue
                        begin
                          # try to nice serialize record
                  Severity: Minor
                  Found in lib/mongodb_logger/logger.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