le0pard/mongodb_logger

View on GitHub

Showing 86 of 86 total issues

Function render has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render: function(args) {

        var detail = args.detail;
        var domainX = args.domainX;

Severity: Minor
Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 1 hr to fix

    Function onclick has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    label.onclick = function(e){
    
                            var disableAllOtherLines = line.series.disabled;
                            if ( ! disableAllOtherLines ) {
                                    for ( var i = 0; i < self.legend.lines.length; i++ ) {
    Severity: Minor
    Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 1 hr to fix

      Function Annotate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      Rickshaw.Graph.Annotate = function(args) {
      
          var graph = this.graph = args.graph;
          this.elements = { timeline: args.element };
          
      Severity: Minor
      Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - 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 add has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def add(severity, message = nil, progname = nil, &block)
            $stdout.puts(message) if ENV['HEROKU_RACK'] # log in stdout on Heroku
            if @level && @level <= severity && (message.present? || progname.present?) && Thread.current[:mongodb_logger_mongo_record].present?
              add_log_message(severity, message, progname)
            end
      Severity: Minor
      Found in lib/mongodb_logger/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

      Function validateSeries has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          this.validateSeries = function(series) {
      
              if (!(series instanceof Array) && !(series instanceof Rickshaw.Series)) {
                  var seriesSignature = Object.prototype.toString.apply(series);
                  throw "series is not an array: " + seriesSignature;
      Severity: Minor
      Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 1 hr to fix

        Function Highlight has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
        
            this.graph = args.graph;
            this.legend = args.legend;
        
        
        Severity: Minor
        Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 1 hr to fix

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

                  this.timeBase = typeof(options.timeBase) === 'undefined' ? Math.floor(new Date().getTime() / 1000) : options.timeBase;
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 55 mins to fix
          app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 2409..2411

          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 53.

          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

                  this.timeBase = typeof(options.timeBase) === 'undefined' ? 
                      Math.floor(new Date().getTime() / 1000) : 
                      options.timeBase;
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 55 mins to fix
          app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 2576..2576

          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 53.

          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

                  this.stackData.hooks.data.forEach( function(entry) {
                      data = entry.f.apply(self, [data]);
                  } );
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 50 mins to fix
          app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 520..522

          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 51.

          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

                  this.stackData.hooks.after.forEach( function(entry) {
                      stackedData = entry.f.apply(self, [data]);
                  } );
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 50 mins to fix
          app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 511..513

          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 51.

          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

          Function formatter has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              formatter: function(series, x, y, formattedX, formattedY, d) {
          Severity: Minor
          Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - About 45 mins to fix

            Function formatKMBT has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            Rickshaw.Fixtures.Number.formatKMBT = function(y) {
                if (y >= 1000000000000)   { return y / 1000000000000 + "T" } 
                else if (y >= 1000000000) { return y / 1000000000 + "B" } 
                else if (y >= 1000000)    { return y / 1000000 + "M" } 
                else if (y >= 1000)       { return y / 1000 + "K" }
            Severity: Minor
            Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - 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

            Function formatBase1024KMGTP has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            Rickshaw.Fixtures.Number.formatBase1024KMGTP = function(y) {
                if (y >= 1125899906842624)  { return y / 1125899906842624 + "P" }
                else if (y >= 1099511627776){ return y / 1099511627776 + "T" }
                else if (y >= 1073741824)   { return y / 1073741824 + "G" }
                else if (y >= 1048576)      { return y / 1048576 + "M" }
            Severity: Minor
            Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js - 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 select_tag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def select_tag(object, name, options_array, options = {})
                value = nil
                value = options.delete(:value) if options[:value]
                value = object.send name if object && object.respond_to?(name)
                attributes = options.map{ |key, val| "#{key}='#{val}'" }
            Severity: Minor
            Found in lib/mongodb_logger/server/helpers/view_helpers.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

            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

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

                                  annotation.boxes.forEach( function(box) {
                                      if ( box.rangeElement ) box.rangeElement.classList.toggle('active');
                                  });
              Severity: Minor
              Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 40 mins to fix
              app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 1080..1082

              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 48.

              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

                              annotation.boxes.forEach( function(box) {
                                  if ( box.rangeElement ) box.rangeElement.classList.add('offscreen');
                              });
              Severity: Minor
              Found in app/assets/javascripts/vendors/rickshaw/rickshaw.js and 1 other location - About 40 mins to fix
              app/assets/javascripts/vendors/rickshaw/rickshaw.js on lines 1094..1096

              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 48.

              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

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

              Severity
              Category
              Status
              Source
              Language