RailsStudyGroup/redditgraphed

View on GitHub

Showing 34 of 97 total issues

Consider simplifying this complex logical expression.
Open

if (this.datasets && this.datasets.length > 1) {
var dataArray,
dataIndex;

for (var i = this.datasets.length - 1; i >= 0; i--) {
Severity: Critical
Found in app/assets/javascripts/Chart.js - About 1 hr to fix

    Function updateScaleRange has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    updateScaleRange: function(datasets){
    var valuesArray = (function(){
    var totalDataArray = [];
    helpers.each(datasets,function(dataset){
    if (dataset.data){
    Severity: Minor
    Found in app/assets/javascripts/Chart.js - About 1 hr to fix

      Function getDefaults has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getDefaults() {
      return {
      tapToDismiss: true,
      toastClass: 'toast',
      containerId: 'toast-container',
      Severity: Minor
      Found in app/assets/javascripts/toastr.js - About 1 hr to fix

        Function buildScale has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        buildScale : function(data){
        this.scale = new Chart.RadialScale({
        display: this.options.showScale,
        fontStyle: this.options.scaleFontStyle,
        fontSize: this.options.scaleFontSize,
        Severity: Minor
        Found in app/assets/javascripts/Chart.js - About 1 hr to fix

          Function medianPosition has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          medianPosition = (function(index) {
          
          // Get all the points at that particular index
          var Elements = [],
          dataCollection,
          Severity: Minor
          Found in app/assets/javascripts/Chart.js - About 1 hr to fix

            Function set has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              NProgress.set = function(n) {
                var started = NProgress.isStarted();
            
                n = clamp(n, Settings.minimum, 1);
                NProgress.status = (n === 1 ? null : n);
            Severity: Minor
            Found in app/assets/javascripts/nprogress.js - About 1 hr to fix

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

              updateScaleRange: function(datapoints){
              var valuesArray = [];
              helpers.each(datapoints,function(segment){
              valuesArray.push(segment.value);
              });
              Severity: Minor
              Found in app/assets/javascripts/Chart.js - About 1 hr to fix

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

                draw : function(ease){
                var easeDecimal = ease || 1,
                ctx = this.chart.ctx;
                this.clear();
                this.scale.draw();
                Severity: Minor
                Found in app/assets/javascripts/Chart.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                  for (var i=0;i<this.valuesCount;i++)
                  {
                  pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.min + (index * this.stepValue)));
                  if (i === 0){
                  ctx.moveTo(pointPosition.x, pointPosition.y);
                  Severity: Major
                  Found in app/assets/javascripts/Chart.js - About 45 mins to fix

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

                    animationLoop = helpers.animationLoop = function(callback,totalSteps,easingString,onProgress,onComplete,chartInstance){
                    Severity: Minor
                    Found in app/assets/javascripts/Chart.js - About 45 mins to fix

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

                      drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx,x,y,width,height,radius){
                      Severity: Minor
                      Found in app/assets/javascripts/Chart.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                        if (pointPosition.x - textWidth < furthestLeft) {
                        furthestLeft = pointPosition.x - textWidth;
                        furthestLeftIndex = i;
                        }
                        Severity: Major
                        Found in app/assets/javascripts/Chart.js - About 45 mins to fix

                          Function calculateScaleRange has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly){
                          Severity: Minor
                          Found in app/assets/javascripts/Chart.js - About 35 mins to fix

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

                              def custom_bootstrap_flash
                                flash_messages = []
                                flash.each do |type, message|
                                  type = 'success' if type == 'notice'
                                  type = 'error'   if type == 'alert'
                            Severity: Minor
                            Found in app/helpers/application_helper.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