18F/openFEC-web-app

View on GitHub

Showing 67 of 188 total issues

Function handleKeydown has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    handleKeydown(e) {
      let highlightCitation = this.state.highlightCitation;

      if(this.state.dropdownVisible) {
        // down arrow or tab
Severity: Minor
Found in static/js/legal/filters/CitationFilter.js - 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

Function drawChart has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

LineChart.prototype.drawChart = function() {
  var entityTotals = this.groupEntityTotals();
  var x = this.setXScale();
  var y = this.setYScale();
  var xAxis = d3.svg.axis()
Severity: Minor
Found in static/js/modules/line-chart.js - About 2 hrs to fix

    Function modalRenderFactory has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function modalRenderFactory(template, fetch) {
      var callback;
      fetch = fetch || identity;
    
      return function(api, data, response) {
    Severity: Minor
    Found in static/js/modules/tables.js - About 1 hr to fix

      Function Filters has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Filters(props) {
        const resultCountChange = props.query.resultCount - props.query.lastResultCount;
      
        return <div>
                  <div className="accordion__content">
      Severity: Minor
      Found in static/js/legal/Filters.js - About 1 hr to fix

        Function SearchResults has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        function SearchResults(props) {
          function highlights(advisory_opinion) {
            return {__html: '&hellip;' + advisory_opinion.highlights }
          }
        
        
        Severity: Minor
        Found in static/js/legal/SearchResults.js - 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

        Function render_candidate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def render_candidate(candidate, committees, cycle, election_full=True):
            # candidate fields will be top-level in the template
            tmpl_vars = candidate
            tmpl_vars['parent'] = 'data'
            tmpl_vars['cycle'] = cycle
        Severity: Minor
        Found in openfecwebapp/views.py - 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

        Function exports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(config) {
          var browserify = {
            debug: true,
            transform: [
              [{global: true}, 'hbsfy']
        Severity: Minor
        Found in karma.conf.js - About 1 hr to fix

          Function renderCandidatePanel has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var renderCandidatePanel = function(showFinancialTotals) {
            return tables.modalRenderFactory(
              candidatesTemplate,
              function(row) {
                var query = URI.parseQuery(window.location.search);
          Severity: Minor
          Found in static/js/modules/table-panels.js - About 1 hr to fix

            Function initDisbursementsTable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function initDisbursementsTable() {
              var $table = $('table[data-type="itemized-disbursements"]');
              var path = ['schedules', 'schedule_b'];
              var opts = {
                // possibility of multiple committees, so split into array
            Severity: Minor
            Found in static/js/pages/candidate-single.js - About 1 hr to fix

              Function initSpendingTables has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function initSpendingTables() {
                $('.data-table').each(function(index, table) {
                  var $table = $(table);
                  var dataType = $table.data('type');
                  var opts = tableOpts[dataType];
              Severity: Minor
              Found in static/js/pages/candidate-single.js - About 1 hr to fix

                Function amendmentVersionDescription has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function amendmentVersionDescription(row) {
                  // Helper function for labeling filings as either an "original" or
                  // a numbered amendment (e.g. "amendment 1" or "amendment 2")
                  // Different filings are coded slightly differently, which makes for some tricky logic
                  var description = '';
                Severity: Minor
                Found in static/js/modules/helpers.js - 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

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

                CycleSelect.prototype.initCyclesMulti = function(selected) {
                  var cycles = _.range(selected - this.duration + 2, selected + 2, 2);
                  var params = this.getParams();
                  var selectedCycle;
                  var cycleId = this.cycleId;
                Severity: Minor
                Found in static/js/modules/cycle-select.js - About 1 hr to fix

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

                  function stateLegend(svg, scale, quantize, quantiles) {
                    // Add legend swatches
                    var legendWidth = 40;
                    var legendBar = 35;
                    var ticks = quantize.ticks(quantiles);
                  Severity: Minor
                  Found in static/js/modules/maps.js - About 1 hr to fix

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

                      render() {
                        return <section className="main__content--full data-container__wrapper">
                          <div id="filters" className="filters is-open">
                            <button className="filters__header filters__toggle js-filter-toggle" type="button">
                              <span className="filters__title">Edit filters</span>
                    Severity: Minor
                    Found in static/js/legal/LegalSearch.js - About 1 hr to fix

                      Function refreshExport has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      DataTable.prototype.refreshExport = function() {
                        if (this.opts.useExport && !this.opts.disableExport) {
                          var numRows = this.api.context[0].fnRecordsTotal();
                          if (numRows > DOWNLOAD_CAP) {
                            this.disableExport({message: DOWNLOAD_MESSAGES.recordCap});
                      Severity: Minor
                      Found in static/js/modules/tables.js - 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

                      Function search has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      ElectionSearch.prototype.search = function(e, opts) {
                        e && e.preventDefault();
                        opts = _.extend({pushState: true}, opts || {});
                        var self = this;
                        var serialized = self.serialize();
                      Severity: Minor
                      Found in static/js/modules/election-search.js - 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

                      Function updateColorScale has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function updateColorScale($container, cached) {
                        $container = $container.closest('#state-maps');
                        var displayed = $container.find('.state-map select').map(function(_, select) {
                          return $(select).val();
                        }).get();
                      Severity: Minor
                      Found in static/js/pages/elections.js - About 1 hr to fix

                        Function render_candidate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        def render_candidate(candidate, committees, cycle, election_full=True):
                            # candidate fields will be top-level in the template
                            tmpl_vars = candidate
                            tmpl_vars['parent'] = 'data'
                            tmpl_vars['cycle'] = cycle
                        Severity: Minor
                        Found in openfecwebapp/views.py - About 1 hr to fix

                          Function ElectionSearch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function ElectionSearch(selector) {
                            this.$elm = $(selector);
                            this.districts = 0;
                            this.serialized = {};
                            this.results = [];
                          Severity: Minor
                          Found in static/js/modules/election-search.js - About 1 hr to fix

                            Function buildTotalLink has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function buildTotalLink(path, getParams) {
                              return function(data, type, row, meta) {
                                data = data || 0;
                                var params = getParams(data, type, row, meta);
                                var span = document.createElement('div');
                            Severity: Minor
                            Found in static/js/modules/column-helpers.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language