flower-pot/veterator

View on GitHub

Showing 4 of 4 total issues

Function initializeChartWithData has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Chart.prototype.initializeChartWithData = function() {
    var self = this;
    d3.json("/sensors/" + this.sensor_id + "/records.json" + location.search, function(error, json) {
        self.data = json.records;
        self.data.forEach(function(d) {
Severity: Major
Found in app/assets/javascripts/chart.js - About 2 hrs to fix

    Function resize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Chart.prototype.resize = function() {
        this.width = parseInt(d3.select(this.selector).style("width")) - this.margin*2;
        this.height = ((parseInt(d3.select(this.selector).style("width"))/16)*9) - this.margin*2;
    
        if (this.interactive) { this.hoverLine.attr('y2', this.height); }
    Severity: Minor
    Found in app/assets/javascripts/chart.js - About 1 hr to fix

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

      Chart.prototype.initializeChart = function() {
          var self = this;
      
          this.xScale = d3.time.scale()
              .range([0, this.width])
      Severity: Minor
      Found in app/assets/javascripts/chart.js - About 1 hr to fix

        Method perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def perform(*args)
            [:daily, :monthly, :yearly].each do |granularity|
              Sensor.all.each do |sensor|
                r = sensor.records.where('granularity = ?', Record.granularities[granularity]).last
                if r.nil?
        Severity: Minor
        Found in app/jobs/aggregate_records_job.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