nacyot/putne

View on GitHub

Showing 66 of 66 total issues

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

        city.append("path")
            .attr("class", "line")
            .attr("d", function(d) { return line(d.values); })
            .style("stroke", function(d) { return color(d.name); });
Severity: Major
Found in app/assets/javascripts/graph/multi_line_chart.js and 1 other location - About 1 hr to fix
app/assets/javascripts/graph/stacked_area_chart.js on lines 68..71

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

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

        browser.append("path")
            .attr("class", "area")
            .attr("d", function(d) { return area(d.values); })
            .style("fill", function(d) { return color(d.name); });
Severity: Major
Found in app/assets/javascripts/graph/stacked_area_chart.js and 1 other location - About 1 hr to fix
app/assets/javascripts/graph/multi_line_chart.js on lines 83..86

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

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

        browser.append("text")
            .datum(function(d) { return {name: d.name, value: d.values[d.values.length - 1]}; })
            .attr("transform", function(d) { return "translate(" + x(d.value.date) + "," + y(d.value.y0 + d.value.y / 2) + ")"; })
Severity: Major
Found in app/assets/javascripts/graph/stacked_area_chart.js and 1 other location - About 1 hr to fix
app/assets/javascripts/graph/multi_line_chart.js on lines 88..90

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

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

        city.append("text")
            .datum(function(d) { return {name: d.name, value: d.values[d.values.length - 1]}; })
            .attr("transform", function(d) { return "translate(" + x(d.value.date) + "," + y(d.value.temperature) + ")"; })
Severity: Major
Found in app/assets/javascripts/graph/multi_line_chart.js and 1 other location - About 1 hr to fix
app/assets/javascripts/graph/stacked_area_chart.js on lines 73..75

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

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

  def register_reeks
    report = MetricFuReport::ReekParser.new report_directory
    smell_category = SmellCategory.find_or_create_by name: "SMELL"
    smell_source = SmellSource.find_or_create_by name: "REEK"
    
Severity: Minor
Found in app/models/concerns/register_report.rb - About 1 hr to fix

    Function d3_pie_chart has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    this.d3_pie_chart = function(selector, data_file = "/d3js/pie.csv"){
        var target = d3.select(selector);
        var parentWidth = target[0][0].parentNode.clientWidth;
    
        var width = parentWidth;
    Severity: Minor
    Found in app/assets/javascripts/graph/pie_chart.js - About 1 hr to fix

      Method register_flogs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def register_flogs
          report = MetricFuReport::FlogParser.new report_directory
      
          score_category = ScoreCategory.find_or_create_by name: "COMPLEXITY"
          score_source = ScoreSource.find_or_create_by name: "FLOG"
      Severity: Minor
      Found in app/models/concerns/register_report.rb - About 1 hr to fix

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

            var line = d3.svg.line()
                .x(function(d) { return x(d.date); })
                .y(function(d) { return y(d.close); });
        Severity: Major
        Found in app/assets/javascripts/graph/line_chart.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/graph/stacked_area_chart.js on lines 31..33

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

        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 area = d3.svg.area()
                .x(function(d) { return x(d.date); })
                .y0(function(d) { return y(d.y0); })
        Severity: Major
        Found in app/assets/javascripts/graph/stacked_area_chart.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/graph/line_chart.js on lines 27..29

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

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

        this.d3_donut_chart = function(selector, data_file = "/d3js/donut.csv"){
            var target = d3.select(selector);
            var parentWidth = target[0][0].parentNode.clientWidth;
        
            var width = parentWidth - 20;
        Severity: Minor
        Found in app/assets/javascripts/graph/donut_chart.js - About 1 hr to fix

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

          this.d3_icecle_chart = function(selector, data_file = "/d3js/flare.json"){
              var target = d3.select(selector);
              var width = target[0][0].parentNode.clientWidth - 40 ;
              var height = width /2;
              var color = d3.scale.category20c();
          Severity: Minor
          Found in app/assets/javascripts/graph/icecle_chart.js - About 1 hr to fix

            Method register_saikuro has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def register_saikuro
                report = MetricFuReport::SaikuroParser.new report_directory
                score_category = ScoreCategory.find_or_create_by name: "COMPLEXITY"
                score_category_loc = ScoreCategory.find_or_create_by name: "LOC"
                score_source = ScoreSource.find_or_create_by name: "SAIKURO"
            Severity: Minor
            Found in app/models/concerns/register_report.rb - About 1 hr to fix

              Method recursive_search_ast has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def recursive_search_ast(ast, name)
                  ast.children.each do |child|
                    if child.class.to_s == "Parser::AST::Node"
                      if (child.type.to_s == "def" or child.type.to_s == "defs") and (child.children[0].to_s == name or child.children[1].to_s == name)
                        @method = child.source_map.expression.to_source
              Severity: Minor
              Found in app/controllers/metrics_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

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

                             var dayLabels = svg.selectAll(".dayLabel")
                                 .data(days)
                                 .enter().append("text")
                                 .text(function (d) { return d; })
                                 .attr("x", 0)
              Severity: Minor
              Found in app/assets/javascripts/graph/day_hour_heatmap.js and 1 other location - About 55 mins to fix
              app/assets/javascripts/graph/day_hour_heatmap.js on lines 47..51

              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

                             var timeLabels = svg.selectAll(".timeLabel")
                                 .data(times)
                                 .enter().append("text")
                                 .text(function(d) { return d; })
                                 .attr("x", function(d, i) { return i * gridSize; })
              Severity: Minor
              Found in app/assets/javascripts/graph/day_hour_heatmap.js and 1 other location - About 55 mins to fix
              app/assets/javascripts/graph/day_hour_heatmap.js on lines 37..41

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

                def register_class_score(category, source)
                  category = ScoreCategory.find_by(name: category) if category.instance_of?(String)
                  source = ScoreSource.find_by(name: source) if source.instance_of?(String)
                  
                  target_classes.includes(:target_methods).each do |klass|
              Severity: Minor
              Found in app/models/concerns/register_report.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

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

                  respond_to do |format|
                    if @project.id?
                      format.html { render text: "aoeuaeou" }
                      format.json { render action: 'show', status: :created, location: @project }
                    else
              Severity: Minor
              Found in app/controllers/projects_controller.rb and 1 other location - About 50 mins to fix
              app/controllers/commit_hook_controller.rb on lines 13..19

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

              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

                  respond_to do |format|
                    if @project.id?
                      format.html { render text: "aoeuaeou" }
                      format.json { render action: 'show', status: :created, location: @project }
                    else
              Severity: Minor
              Found in app/controllers/commit_hook_controller.rb and 1 other location - About 50 mins to fix
              app/controllers/projects_controller.rb on lines 108..114

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

              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 g = svg.selectAll(".arc")
                          .data(pie(data))
                          .enter().append("g")
                          .attr("class", "arc");
              Severity: Minor
              Found in app/assets/javascripts/graph/pie_chart.js and 1 other location - About 50 mins to fix
              app/assets/javascripts/graph/donut_chart.js on lines 34..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 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

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

                      var g = svg.selectAll(".arc")
                          .data( pie(data) )
                          .enter().append("g")
                          .attr("class", "arc");
              Severity: Minor
              Found in app/assets/javascripts/graph/donut_chart.js and 1 other location - About 50 mins to fix
              app/assets/javascripts/graph/pie_chart.js on lines 38..41

              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

              Severity
              Category
              Status
              Source
              Language