Vizzuality/gfw-climate

View on GitHub

Showing 1,213 of 1,213 total issues

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

define(['backbone', 'jquery'], function(Backbone, $) {
  var CountriesCollection = Backbone.Model.extend({
    url: '/api/countries/',

    parse: function(data) {
app/assets/javascripts/compare/collections/WidgetsCollection.js on lines 1..11

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

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

          case 'areas-interest':
            widgets = widgets[forestAndCarbon];
            areas = this.presenter.countryModel.get('areas_of_interest');
            areas = areas.length > 0 ? areas : null;
            break;
app/assets/javascripts/countries/views/show/CountryWidgetsModalView.js on lines 66..70

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

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

      render: function() {
        this._setUpGraph();
        this._drawGrid();
        this._setAxisScale();
        this._setDomain();
app/assets/javascripts/countries/views/report/HistoricalTrendChartView.js on lines 123..129
app/assets/javascripts/countries/views/report/SummaryChartView.js on lines 157..163
app/assets/javascripts/insights/views/glad-alerts/InsightsGladAlertsChartView.js on lines 224..230

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

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

          case 'subnational':
            widgets = widgets[forestAndCarbon];
            jurisdictions = this.presenter.countryModel.get('jurisdictions');
            jurisdictions = jurisdictions.length > 0 ? jurisdictions : null;
            break;
app/assets/javascripts/countries/views/show/CountryWidgetsModalView.js on lines 72..76

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

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

      renderIsoLayers: function(layers) {
        var country = _.find(
          amplify.store('countries'),
          _.bind(function(country) {
            return country.iso === this.iso;
Severity: Minor
Found in app/assets/javascripts/map/views/LayersNavView.js - About 1 hr to fix

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

          _player: function() {
            if (this.$play_pause.hasClass('is-playing')) {
              window.setTimeout(
                function() {
                  this.progression += 100 / this.ticks;
    Severity: Minor
    Found in app/assets/javascripts/embed/views/pantropical/PantropicalView.js - About 1 hr to fix

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

            formatXaxis: function() {
              var self = this;
              d3
                .select('.xaxis')
                .selectAll('text')
      Severity: Minor
      Found in app/assets/javascripts/abstract/timeline/TimelineYearClass.js - About 1 hr to fix

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

              _drawDashedLine: function() {
                var _this = this;
                var allYData = _.pluck(this.chartData, this.dataColumns.dashed.y);
                var allXData = _.pluck(this.chartData, this.dataColumns.dashed.x);
        
        

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

                _drawDots: function() {
                  var _this = this;
                  var dotsGroup = this.svg
                    .append('g')
                    .attr('class', 'dots-group')

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

                  selectYear: function(val) {
                    // LEFT
                    this.ext.left = this.xscale(val);
            
                    this.domain.attr('x2', this.ext.right);
            Severity: Minor
            Found in app/assets/javascripts/abstract/timeline/TimelineYearClass.js - About 1 hr to fix

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

                    render: function() {
                      var $spinner = this.$el.find('#spinner2');
                      var τ = 2 * Math.PI;
                      var width = $spinner.width();
                      var height = $spinner.height();
              Severity: Minor
              Found in app/assets/javascripts/map/views/tabs/SpinnerView.js - About 1 hr to fix

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

                  var PieChart = function(options) {
                    this.options = options;
                    this.data = this._defindeData(options.data);
                
                    enquire.register(
                Severity: Minor
                Found in app/assets/javascripts/widgets/indicators/pie/PieChart.js - About 1 hr to fix

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

                      LineChart.prototype.setListeners = function() {
                        var formatDate = d3.time.format('%Y');
                        var bisectDate = d3.bisector(function(d) {
                          return d.year;
                        }).left;

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

                          render: function() {
                            var view = this.presenter.status.get('view');
                            var options = {
                              country: this.presenter.status.get('country'),
                              parent: this.$el.find('.reports-grid')
                    Severity: Minor
                    Found in app/assets/javascripts/countries/views/show/WidgetGridView.js - About 1 hr to fix

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

                            getCountryStats: function(params) {
                              return new Promise(
                                function(resolve, reject) {
                                  this.getClimateConfig()
                                    .then(
                      Severity: Minor
                      Found in app/assets/javascripts/services/CountryService.js - About 1 hr to fix

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

                            StackedChart.prototype._drawAxes = function() {
                              var self = this;
                              var tickSizeX = $(window).width() > 1025 ? 1 : 2;
                              var tickFormatY = this.unit != 'percentage' ? '.2s' : '.2f';
                              this.xAxis = d3.svg
                        Severity: Minor
                        Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

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

                              var StackedChart = function(options) {
                                this.svg;
                                this.options = options;
                                this.parent = options.parent;
                                this.data = options.data;
                          Severity: Minor
                          Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

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

                                  _setAxisScale: function() {
                                    var _this = this;
                                    var xTickFormat = d3.time.format(_this.defaults.dateFormat);
                                    var yTickFormat = function(d) {
                                      return d > 999 ? d / 1000 + 'k' : d;
                            Severity: Minor
                            Found in app/assets/javascripts/countries/views/report/SummaryChartView.js - About 1 hr to fix

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

                                  LineChart.prototype._drawAxes = function() {
                                    var self = this;
                                    var tickSizeX = $(window).width() > 1025 ? 1 : 2;
                                    var tickFormatY = this.unit != 'percentage' ? '.2s' : '.2f';
                                    this.xAxis = d3.svg

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

                                      _player: function() {
                                        if (this.$play_pause.hasClass('is-playing')) {
                                          window.setTimeout(
                                            function() {
                                              this.progression += 100 / this.ticks;
                                Severity: Minor
                                Found in app/assets/javascripts/countries/views/CountryPantropicalView.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language