RailsStudyGroup/redditgraphed

View on GitHub

Showing 97 of 97 total issues

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

removeData : function(){
this.scale.removeXLabel();
//Then re-render the chart.
helpers.each(this.datasets,function(dataset){
dataset.points.shift();
Severity: Major
Found in app/assets/javascripts/Chart.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/Chart.js on lines 2144..2151

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

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

initialize: function(data){
this.segments = [];
//Declare segment class as a chart instance specific class, so it can share props for this instance
this.SegmentArc = Chart.Arc.extend({
showStroke : this.options.segmentShowStroke,
Severity: Minor
Found in app/assets/javascripts/Chart.js - About 2 hrs to fix

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

    if (a < Math.abs(1)) {
    a = 1;
    s = p / 4;
    } else s = p / (2 * Math.PI) * Math.asin(1 / a);
    Severity: Major
    Found in app/assets/javascripts/Chart.js and 2 other locations - About 1 hr to fix
    app/assets/javascripts/Chart.js on lines 549..552
    app/assets/javascripts/Chart.js on lines 562..565

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

    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 3 locations. Consider refactoring.
    Open

    if (a < Math.abs(1)) {
    a = 1;
    s = p / 4;
    } else s = p / (2 * Math.PI) * Math.asin(1 / a);
    Severity: Major
    Found in app/assets/javascripts/Chart.js and 2 other locations - About 1 hr to fix
    app/assets/javascripts/Chart.js on lines 536..539
    app/assets/javascripts/Chart.js on lines 549..552

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

    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 3 locations. Consider refactoring.
    Open

    if (a < Math.abs(1)) {
    a = 1;
    s = p / 4;
    } else s = p / (2 * Math.PI) * Math.asin(1 / a);
    Severity: Major
    Found in app/assets/javascripts/Chart.js and 2 other locations - About 1 hr to fix
    app/assets/javascripts/Chart.js on lines 536..539
    app/assets/javascripts/Chart.js on lines 562..565

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

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

      var css = (function() {
        var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
            cssProps    = {};
    
        function camelCase(string) {
    Severity: Minor
    Found in app/assets/javascripts/nprogress.js - About 1 hr to fix

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

      inner : {
      x : MiddlePoint.x-fa*(AfterPoint.x-FirstPoint.x),
      y : MiddlePoint.y-fa*(AfterPoint.y-FirstPoint.y)
      },
      Severity: Major
      Found in app/assets/javascripts/Chart.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/Chart.js on lines 316..319

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

      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

      outer : {
      x: MiddlePoint.x+fb*(AfterPoint.x-FirstPoint.x),
      y : MiddlePoint.y+fb*(AfterPoint.y-FirstPoint.y)
      }
      Severity: Major
      Found in app/assets/javascripts/Chart.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/Chart.js on lines 312..315

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

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

        def create
          build_resource(sign_up_params)
          resource.name = params[:user][:name]
          resource.save
          yield resource if block_given?
      Severity: Minor
      Found in app/controllers/users/registrations_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

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

      var datasetObject = {
      label: dataset.label || null,
      fillColor : dataset.fillColor,
      strokeColor : dataset.strokeColor,
      pointColor : dataset.pointColor,
      Severity: Major
      Found in app/assets/javascripts/Chart.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/Chart.js on lines 2460..2467

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

      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

      var datasetObject = {
      label : dataset.label || null,
      fillColor : dataset.fillColor,
      strokeColor : dataset.strokeColor,
      pointColor : dataset.pointColor,
      Severity: Major
      Found in app/assets/javascripts/Chart.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/Chart.js on lines 3065..3072

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

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

      calculateXLabelRotation : function(){
      //Get the width of each grid by calculating the difference
      //between x offsets between 0 and 1.
      
      this.ctx.font = this.font;
      Severity: Minor
      Found in app/assets/javascripts/Chart.js - About 1 hr to fix

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

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

                  function success(message, title, optionsOverride) {
                  return notify({
                  type: toastType.success,
                  iconClass: getOptions().iconClasses.success,
                  message: message,
                  Severity: Major
                  Found in app/assets/javascripts/toastr.js and 2 other locations - About 1 hr to fix
                  app/assets/javascripts/toastr.js on lines 60..68
                  app/assets/javascripts/toastr.js on lines 81..89

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

                  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 3 locations. Consider refactoring.
                  Open

                  function info(message, title, optionsOverride) {
                  return notify({
                  type: toastType.info,
                  iconClass: getOptions().iconClasses.info,
                  message: message,
                  Severity: Major
                  Found in app/assets/javascripts/toastr.js and 2 other locations - About 1 hr to fix
                  app/assets/javascripts/toastr.js on lines 72..80
                  app/assets/javascripts/toastr.js on lines 81..89

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

                  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 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
                    Severity
                    Category
                    Status
                    Source
                    Language