le0pard/mongodb_logger

View on GitHub

Showing 86 of 86 total issues

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            Array.prototype.forEach.call(nodes[0], function(n) {
                n.setAttribute('fill', series.color);
            } );
Severity: Minor
Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 35 mins to fix
app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 2301..2303

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            Array.prototype.forEach.call(nodes[0], function(n) {
                n.setAttribute('fill', series.color);
            } );
Severity: Minor
Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 35 mins to fix
app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 2139..2141

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    var annotationRangeEnd   = Math.min( self.graph.x(box.end), self.graph.x.range()[1] );
Severity: Minor
Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 30 mins to fix
app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 1135..1135

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                                  annotationRangeStart = Math.max( self.graph.x(box.end), self.graph.x.range()[0] );
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 30 mins to fix
          app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 1130..1130

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 45.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      var nodes = graph.vis.selectAll("path")
                          .data(series.stack)
                          .enter().append("svg:rect")
                          .attr("x", function(d) { return graph.x(d.x) + barXOffset })
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 30 mins to fix
          app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 2294..2297

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 45.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      var nodes = graph.vis.selectAll("path")
                          .data(series.stack)
                          .enter().append("svg:circle")
                          .attr("cx", function(d) { return graph.x(d.x) })
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 30 mins to fix
          app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 2130..2133

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 45.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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 >= 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

                Severity
                Category
                Status
                Source
                Language