18F/openFEC-web-app

View on GitHub

Showing 188 of 188 total issues

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

                <CitationFilter handleChange={props.setQuery} getResults={props.getResults}
                    key="ao_regulatory_citation" name="ao_regulatory_citation" label="Regulatory citation" instantQuery={props.instantQuery}
                    citationType="regulation" value={props.query.ao_regulatory_citation}
                    resultCountChange={resultCountChange} lastFilter={props.query.lastFilter}/>
Severity: Major
Found in static/js/legal/Filters.js and 1 other location - About 3 hrs to fix
static/js/legal/Filters.js on lines 41..44

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

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

                <CitationFilter handleChange={props.setQuery} getResults={props.getResults}
                    key="ao_statutory_citation" name="ao_statutory_citation" label="Statutory citation" instantQuery={props.instantQuery}
                    citationType="statute" value={props.query.ao_statutory_citation}
                    resultCountChange={resultCountChange} lastFilter={props.query.lastFilter}/>
Severity: Major
Found in static/js/legal/Filters.js and 1 other location - About 3 hrs to fix
static/js/legal/Filters.js on lines 37..40

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

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

function filterSuccessUpdates(changeCount) {
  // on filter change update:
  // - loading/success status
  // - count change message

Severity: Major
Found in static/js/modules/tables.js - About 2 hrs to fix

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

        columns: [{
          data: 'state_full',
          width: '50%',
          className: 'all',
          render: function(data, type, row, meta) {
    Severity: Major
    Found in static/js/pages/candidate-single.js and 1 other location - About 2 hrs to fix
    static/js/pages/committee-single.js on lines 52..63

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

    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

      {
        data: 'state_full',
        width: '50%',
        className: 'all',
        render: function(data, type, row, meta) {
    Severity: Major
    Found in static/js/pages/committee-single.js and 1 other location - About 2 hrs to fix
    static/js/pages/candidate-single.js on lines 362..373

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

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

    function SearchResults(props) {
      function highlights(advisory_opinion) {
        return {__html: '&hellip;' + advisory_opinion.highlights }
      }
    
    
    Severity: Major
    Found in static/js/legal/SearchResults.js - About 2 hrs to fix

      File line-chart.js has 284 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      /* global module, DEFAULT_TIME_PERIOD */
      var $ = require('jquery');
      var _ = require('underscore');
      Severity: Minor
      Found in static/js/modules/line-chart.js - About 2 hrs to fix

        File helpers.js has 270 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        /* global Intl, BASE_PATH, API_LOCATION, API_VERSION, API_KEY */
        
        var URI = require('urijs');
        Severity: Minor
        Found in static/js/modules/helpers.js - About 2 hrs to fix

          Function render_committee has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          def render_committee(committee, candidates, cycle, redirect_to_previous):
              # committee fields will be top-level in the template
              tmpl_vars = committee
          
              tmpl_vars['parent'] = 'data'
          Severity: Minor
          Found in openfecwebapp/views.py - About 2 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

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

          LineChart.prototype.goToNextMonth = function() {
            if (this.nextDatum) {
              this.moveCursor(this.nextDatum);
            } else if (this.cycle < MAX_CYCLE) {
              this.startCursorAtEnd = false;
          Severity: Major
          Found in static/js/modules/line-chart.js and 1 other location - About 2 hrs to fix
          static/js/modules/line-chart.js on lines 342..349

          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

          LineChart.prototype.goToPreviousMonth = function() {
            if (this.prevDatum) {
              this.moveCursor(this.prevDatum);
            } else if (this.cycle > MIN_CYCLE) {
              this.startCursorAtEnd = true;
          Severity: Major
          Found in static/js/modules/line-chart.js and 1 other location - About 2 hrs to fix
          static/js/modules/line-chart.js on lines 333..340

          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

          @app.route('/legal/search/regulations/')
          @use_kwargs({
              'query': fields.Str(load_from='search'),
              'offset': fields.Int(missing=0),
          })
          Severity: Major
          Found in openfecwebapp/routes.py and 1 other location - About 2 hrs to fix
          openfecwebapp/routes.py on lines 514..520

          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

          @app.route('/legal/search/statutes/')
          @use_kwargs({
              'query': fields.Str(load_from='search'),
              'offset': fields.Int(missing=0),
          })
          Severity: Major
          Found in openfecwebapp/routes.py and 1 other location - About 2 hrs to fix
          openfecwebapp/routes.py on lines 547..553

          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

          election_sensitive_reports = OrderedDict([
              ('12P', 'Pre-primary'),
              ('12C', 'Pre-convention'),
              ('12G', 'Pre-general'),
              ('12R', 'Pre-runoff'),
          Severity: Major
          Found in openfecwebapp/constants.py and 1 other location - About 2 hrs to fix
          openfecwebapp/constants.py on lines 324..336

          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

                  'presidential': OrderedDict([
                      ('F3P-16', 'Federal funds (Line 16)'),
                      ('F3P-17A', 'Contributions from individuals (Line 17ai)'),
                      ('F3P-17B', 'Contributions from political party committees (Line 17b)'),
                      ('F3P-17C', 'Contributions from other political committees (Line 17c)'),
          Severity: Major
          Found in openfecwebapp/constants.py and 1 other location - About 2 hrs to fix
          openfecwebapp/constants.py on lines 196..208

          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

          File election-search.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict';
          
          /* global window */
          
          var $ = require('jquery');
          Severity: Minor
          Found in static/js/modules/election-search.js - About 2 hrs to fix

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

                              <DateFilter key="request_date" label="Request date" min_name="ao_min_request_date" max_name="ao_max_request_date"
                                min_value={props.query.ao_min_request_date} max_value={props.query.ao_max_request_date}
                                instantQuery={props.instantQuery} setQuery={props.setQuery} />
            Severity: Major
            Found in static/js/legal/Filters.js and 1 other location - About 2 hrs to fix
            static/js/legal/Filters.js on lines 47..49

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

            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

                              <DateFilter key="issue_date" label="Issued date" min_name="ao_min_issue_date" max_name="ao_max_issue_date"
                                min_value={props.query.ao_min_issue_date} max_value={props.query.ao_max_issue_date}
                                instantQuery={props.instantQuery} setQuery={props.setQuery} />
            Severity: Major
            Found in static/js/legal/Filters.js and 1 other location - About 2 hrs to fix
            static/js/legal/Filters.js on lines 50..52

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

            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 views.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import datetime
            
            import furl
            
            from flask.views import MethodView
            Severity: Minor
            Found in openfecwebapp/views.py - About 2 hrs to fix

              Function stateMap has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function stateMap($elm, data, width, height, min, max, addLegend, addTooltips) {
                var svg = d3.select($elm[0])
                  .append('svg')
                    .attr('width', width)
                    .attr('height', height);
              Severity: Major
              Found in static/js/modules/maps.js - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language