apeeyush/Data-Analytics-Log-Manager

View on GitHub

Showing 34 of 34 total issues

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

var sum_measure = function() {
    var self = this;
    self.name = ko.observable('sum_measure');
    self.filter = ko.observableArray();
    self.key = ko.observable('key');
Severity: Major
Found in app/assets/javascripts/knockout_binding.js and 1 other location - About 4 hrs to fix
app/assets/javascripts/knockout_binding.js on lines 54..64

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

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 value_measure = function() {
    var self = this;
    self.name = ko.observable('value_measure');
    self.filter = ko.observableArray();
    self.key = ko.observable('key');
Severity: Major
Found in app/assets/javascripts/knockout_binding.js and 1 other location - About 4 hrs to fix
app/assets/javascripts/knockout_binding.js on lines 42..52

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

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

    if ( parsed_query.group === undefined || parsed_query.group.length === 0) {
      $.ajax({
        type: "POST",
        url: "/table_transform",
        data: $('#transformation_form').serialize(),
Severity: Major
Found in app/assets/javascripts/data_interactive.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/data_interactive.js on lines 23..37

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

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

    } else {
      $.ajax({
        type: "POST",
        url: "/group_transform",
        data: $('#transformation_form').serialize(),
Severity: Major
Found in app/assets/javascripts/data_interactive.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/data_interactive.js on lines 9..23

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

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 monitor has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function monitor(){
  // Collect parameters for HTML form fields
  var application = $('#monitor').find("select[name='monitor[application]']").val();
  var activity = $('#monitor').find("select[name='monitor[activity]']").val();
  // Initialize graph
Severity: Major
Found in app/assets/javascripts/dashboard.js - About 3 hrs to fix

    Function QueryViewModel has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function QueryViewModel() {
        //Data
        var self = this;
        this.filter = ko.observableArray();
        this.filter_having_keys = ko.observable({
    Severity: Major
    Found in app/assets/javascripts/knockout_binding.js - About 2 hrs to fix

      Function doGroupAnalysis has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function doGroupAnalysis(data) {
        var parent_keys = data.template.parent_keys;
        var child_keys = data.template.child_keys;
        var kParentCollectionName = "Parent Table";
        var kChildCollectionName = "Child Table";
      Severity: Major
      Found in app/assets/javascripts/codap.js - About 2 hrs to fix

        Method filter has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.filter(filter_list)
            logs = self
            logs_columns = Log.column_lists
            string_columns = logs_columns["string_columns"]
            time_columns = logs_columns["time_columns"]
        Severity: Minor
        Found in app/models/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

        Function doSingleTableAnalysis has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function doSingleTableAnalysis(data){
          var kParentCollectionName = "Parent Table";
        
          codapPhone.call({
            action: 'reset'
        Severity: Minor
        Found in app/assets/javascripts/codap.js - About 1 hr to fix

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

            def index
              query = JSON.parse(json_escape(params["json-textarea"]))
          
              logs = Log.access_filter(current_user)
              logs = logs.filter(query["filter"]) if (query["filter"].present?)
          Severity: Minor
          Found in app/controllers/table_transform_controller.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 compute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.compute(logs, parent, synthetic_data, parents_list, child_keys)
              computed_logs = []
              if synthetic_data["rule"] != nil && synthetic_data["rule"]["pattern"] != nil
                pattern = synthetic_data["rule"]["pattern"]
              end
          Severity: Minor
          Found in lib/add_synthetic_data.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 index has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              if @query["group"] != nil && %w{username activity application session event}.include?(@query["group"])
                initialize_group_transform
                if @query["child_query"].present?
                  if @query["child_query"]["add_child_data"] == true
          Severity: Minor
          Found in app/controllers/group_transform_controller.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 filter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.filter(filter_list)
              logs = self
              logs_columns = Log.column_lists
              string_columns = logs_columns["string_columns"]
              time_columns = logs_columns["time_columns"]
          Severity: Minor
          Found in app/models/log.rb - About 1 hr to fix

            Method compute has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.compute(logs, parent, synthetic_data, parents_list, child_keys)
                computed_logs = []
                if synthetic_data["rule"] != nil && synthetic_data["rule"]["pattern"] != nil
                  pattern = synthetic_data["rule"]["pattern"]
                end
            Severity: Minor
            Found in lib/add_synthetic_data.rb - About 1 hr to fix

              Function fnServerParams has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  fnServerParams: function(aoData) {
                    var activityName, applicationName, endPeriod, startPeriod, timeZone;
                    applicationName = $("#filter_application").val();
                    aoData.push({
                      name: "applicationName",
              Severity: Minor
              Found in app/assets/javascripts/logs.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                          if key != "sessionID" && key != "uname" && key != "application" && key != "activity" && key != "event" && key != "timestamp" && key != "parameters"
                            new_log[:extras][key] = value
                          end
                Severity: Major
                Found in app/controllers/api/is_controller.rb - About 1 hr to fix

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

                        for (var i = 0; i < eventsLength; i++) {
                          $("#events-list").append('<li>' + data["events"][i] + '</li>');
                        }
                  Severity: Minor
                  Found in app/assets/javascripts/pages.js and 1 other location - About 55 mins to fix
                  app/assets/javascripts/pages.js on lines 23..25

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

                  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

                        for (var i = 0; i < keysLength; i++) {
                          $("#keys-list").append('<li>' + data["keys"][i] + '</li>');
                        }
                  Severity: Minor
                  Found in app/assets/javascripts/pages.js and 1 other location - About 55 mins to fix
                  app/assets/javascripts/pages.js on lines 19..21

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

                  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 value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def value(key)
                        if self[key].present?
                        self[key].class != ActiveSupport::TimeWithZone ? self[key] : self[key].to_i
                      elsif self[:parameters].present? && self[:parameters][key].present?
                        return self[:parameters][key]
                  Severity: Minor
                  Found in app/models/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 index has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def index
                        # If the request body contains a single log (request body is not an array)
                        if ( !JSON.parse(request.body.read).is_a?(Array) )
                          log_data = JSON.parse(request.body.read)
                          status, log = create_new_is_log(log_data)
                  Severity: Minor
                  Found in app/controllers/api/is_controller.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

                  Severity
                  Category
                  Status
                  Source
                  Language