18F/openFEC-web-app

View on GitHub

Showing 188 of 188 total issues

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

var receipts = [
  {
    data: 'contributor',
    orderable: false,
    className: 'all',
Severity: Major
Found in static/js/modules/columns.js and 1 other location - About 1 day to fix
static/js/modules/columns.js on lines 400..438

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

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 individualContributions = [
  {
    data: 'contributor',
    orderable: false,
    className: 'all hide-panel-tablet',
Severity: Major
Found in static/js/modules/columns.js and 1 other location - About 1 day to fix
static/js/modules/columns.js on lines 483..525

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

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

File committee-single.js has 609 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/* global document, context */

var $ = require('jquery');
Severity: Major
Found in static/js/pages/committee-single.js - About 1 day to fix

    File constants.py has 604 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from collections import OrderedDict
    
    START_YEAR = 1979
    END_YEAR = 2018
    DEFAULT_TIME_PERIOD = 2018
    Severity: Major
    Found in openfecwebapp/constants.py - About 1 day to fix

      File columns.js has 602 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      var _ = require('underscore');
      
      var columnHelpers = require('./column-helpers');
      Severity: Major
      Found in static/js/modules/columns.js - About 1 day to fix

        File tables.js has 569 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        var $ = require('jquery');
        var _ = require('underscore');
        
        
        Severity: Major
        Found in static/js/modules/tables.js - About 1 day to fix

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

          $(document).ready(function() {
            var $table = $('#results');
            new tables.DataTable($table, {
              autoWidth: false,
              title: 'Receipts',
          Severity: Major
          Found in static/js/pages/receipts.js and 1 other location - About 1 day to fix
          static/js/pages/disbursements.js on lines 14..47

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

          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

          $(document).ready(function() {
            var $table = $('#results');
            new tables.DataTable($table, {
              autoWidth: false,
              title: 'Disbursements',
          Severity: Major
          Found in static/js/pages/disbursements.js and 1 other location - About 1 day to fix
          static/js/pages/receipts.js on lines 12..45

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

          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

          File elections.js has 500 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict';
          
          /* global document, context */
          
          var d3 = require('d3');
          Severity: Minor
          Found in static/js/pages/elections.js - About 1 day to fix

            File routes.py has 456 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import http
            
            import datetime
            import re
            
            
            Severity: Minor
            Found in openfecwebapp/routes.py - About 6 hrs to fix

              File candidate-single.js has 430 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              'use strict';
              
              /* global require, document, context, WEBMANAGER_EMAIL */
              
              var $ = require('jquery');
              Severity: Minor
              Found in static/js/pages/candidate-single.js - About 6 hrs to fix

                Function Tags has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                Open

                function Tags(props) {
                  const namedFields = [];
                  Array.prototype.push.apply(namedFields, requestorOptions);
                  Array.prototype.push.apply(namedFields, documentTypes);
                  namedFields.push({value: 'ao_is_pending', text: "Pending"});
                Severity: Minor
                Found in static/js/legal/Tags.js - About 5 hrs 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

                Function initContributionsTables has 123 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function initContributionsTables() {
                  var $allTransactions = $('table[data-type="individual-contributions"]');
                  var $contributionSize = $('table[data-type="contribution-size"]');
                  var $contributorState = $('table[data-type="contributor-state"]');
                  var displayCycle = helpers.formatCycleRange($allTransactions.data('cycle'), 2);
                Severity: Major
                Found in static/js/pages/candidate-single.js - About 4 hrs to fix

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

                  @app.route('/committees/')
                  @use_kwargs({
                    'page': fields.Int(missing=1)
                  })
                  def committees( **kwargs):
                  Severity: Major
                  Found in openfecwebapp/routes.py and 1 other location - About 4 hrs to fix
                  openfecwebapp/routes.py on lines 141..155

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

                  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

                  @app.route('/candidates/')
                  @use_kwargs({
                    'page': fields.Int(missing=1)
                  })
                  def candidates(**kwargs):
                  Severity: Major
                  Found in openfecwebapp/routes.py and 1 other location - About 4 hrs to fix
                  openfecwebapp/routes.py on lines 174..188

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

                  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

                      if top_category in ['pac']:
                          top_raisers = api_caller.load_top_pacs('-receipts', cycle=cycle, per_page=10)
                      elif top_category in ['party']:
                          top_raisers = api_caller.load_top_parties('-receipts', cycle=cycle, per_page=10)
                      else:
                  Severity: Major
                  Found in openfecwebapp/routes.py and 1 other location - About 4 hrs to fix
                  openfecwebapp/routes.py on lines 437..442

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

                  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

                      if top_category in ['pac']:
                          top_spenders = api_caller.load_top_pacs('-disbursements', cycle=cycle, per_page=10)
                      elif top_category in ['party']:
                          top_spenders = api_caller.load_top_parties('-disbursements', cycle=cycle, per_page=10)
                      else:
                  Severity: Major
                  Found in openfecwebapp/routes.py and 1 other location - About 4 hrs to fix
                  openfecwebapp/routes.py on lines 405..410

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

                  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

                    if (query.tab === 'raising') {
                      $.getJSON(mapUrl).done(function(data) {
                        maps.stateMap($map, data, 400, 300, null, null, true, true);
                      });
                    } else {
                  Severity: Major
                  Found in static/js/pages/candidate-single.js and 1 other location - About 4 hrs to fix
                  static/js/pages/committee-single.js on lines 630..642

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

                  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

                    if (query.tab === 'raising') {
                      $.getJSON(mapUrl).done(function(data) {
                        maps.stateMap($map, data, 400, 300, null, null, true, true);
                      });
                    } else {
                  Severity: Major
                  Found in static/js/pages/committee-single.js and 1 other location - About 4 hrs to fix
                  static/js/pages/candidate-single.js on lines 469..481

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

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

                  def load_legal_mur(mur_no):
                  
                      url = '/legal/docs/murs/'
                      mur = _call_api(url, parse.quote(mur_no))
                  
                  
                  Severity: Minor
                  Found in openfecwebapp/api_caller.py - About 4 hrs 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