18F/openFEC-web-app

View on GitHub

Showing 67 of 188 total issues

Function amendmentVersionDescription has 26 lines of code (exceeds 25 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

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

    TopEntities.prototype.formatData = function(result, rank) {
      var data;
      if (this.category === 'candidates') {
        data = {
          name: result.name,
    Severity: Minor
    Found in static/js/modules/top-entities.js - About 1 hr to fix

      Function stateMap has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function stateMap($elm, data, width, height, min, max, addLegend, addTooltips) {
      Severity: Major
      Found in static/js/modules/maps.js - About 1 hr to fix

        Function renderCandidatePanel has a Cognitive Complexity of 8 (exceeds 5 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 45 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

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

        def search():
            """Renders the top-level /data page.
        
            If there's a query string, it will
            load candidate and committee search results.
        Severity: Minor
        Found in openfecwebapp/routes.py - About 45 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

        Function load_with_nested has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def load_with_nested(primary_type, primary_id, secondary_type, cycle=None,
        Severity: Minor
        Found in openfecwebapp/api_caller.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                if ($elm.hasClass('tt-input')) {
                  // show message after generated checkbox (last item in list)
                  $label = $('[data-filter="typeahead"] li').last();
                  filterAction = 'Filter added';
                }
          Severity: Major
          Found in static/js/modules/tables.js - About 45 mins to fix

            Function drawResult has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            ElectionSearch.prototype.drawResult = function(result) {
              var election = this.formatResult(result, this);
              var upcomingElections = _.filter(this.upcomingElections, function(upcoming) {
                if (election.office === 'H') {
                  return upcoming.election_state === election.state &&
            Severity: Minor
            Found in static/js/modules/election-search.js - About 45 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

            Function ensureWidgets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            DataTable.prototype.ensureWidgets = function() {
              if (this.hasWidgets) { return; }
              this.$processing = $('<div class="overlay is-loading"></div>').hide();
              this.$body.before(this.$processing);
            
            
            Severity: Minor
            Found in static/js/modules/tables.js - About 45 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

            Function load_legal_search_results has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def load_legal_search_results(query, query_type='all', offset=0, limit=20, **kwargs):
                filters = dict((key, value) for key, value in kwargs.items() if value)
            
                if query or query_type in ['advisory_opinions', 'murs']:
                    filters['hits_returned'] = limit
            Severity: Minor
            Found in openfecwebapp/api_caller.py - About 45 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

            Avoid deeply nested control flow statements.
            Open

                                if 'uscode' in url:
                                    section = re.search('section=([0-9]+)', url).group(1)
                                    citations.append({'text': section, 'url': url})
                                if 'cfr' in url:
            Severity: Major
            Found in openfecwebapp/api_caller.py - About 45 mins to fix

              Function collate_dispositions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def collate_dispositions(dispositions):
                  """ Collate dispositions - group them by disposition, penalty """
                  collated_dispositions = OrderedDict()
                  for row in dispositions:
                      if row['disposition'] in collated_dispositions:
              Severity: Minor
              Found in openfecwebapp/api_caller.py - About 45 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

              Avoid deeply nested control flow statements.
              Open

                                  if 'cfr' in url:
                                      title_no = re.search('titlenum=([0-9]+)', url).group(1)
                                      part_no = re.search('partnum=([0-9]+)', url).group(1)
                                      section_no = re.search('sectionnum=([0-9]+)', url).group(1)
                                      text = '%s C.F.R. %s.%s' % (title_no, part_no, section_no)
              Severity: Major
              Found in openfecwebapp/api_caller.py - About 45 mins to fix

                Function murs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def murs(query, offset, mur_no=None, mur_respondents=None, mur_election_cycles=None,
                Severity: Minor
                Found in openfecwebapp/routes.py - About 45 mins to fix

                  Function load_legal_search_results has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def load_legal_search_results(query, query_type='all', offset=0, limit=20, **kwargs):
                  Severity: Minor
                  Found in openfecwebapp/api_caller.py - About 35 mins to fix

                    Function load_nested_type has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def load_nested_type(parent_type, c_id, nested_type, *path, **filters):
                    Severity: Minor
                    Found in openfecwebapp/api_caller.py - About 35 mins to fix

                      Function makeSizeColumn has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      var makeSizeColumn = _.partial(makeCommitteeColumn, _, function(data, type, row, meta, column) {
                      Severity: Minor
                      Found in static/js/pages/elections.js - About 35 mins to fix

                        Function deploy has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def deploy(ctx, space=None, branch=None, login=None, yes=False):
                        Severity: Minor
                        Found in tasks.py - About 35 mins to fix

                          Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            constructor(props) {
                              super(props);
                              const initState = URI.parseQuery(window.location.search);
                              initState.q = initState.search;
                              initState.type = initState.search_type;
                          Severity: Minor
                          Found in static/js/legal/LegalSearch.js - About 35 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

                          Function CheckboxList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function CheckboxList(props) {
                            function handleCheckboxListChange(e) {
                              const newEvent = { target: { name: props.name, value: props.value} };
                          
                              // value should be set to an array of values. If the array is empty,
                          Severity: Minor
                          Found in static/js/legal/filters/CheckboxList.js - About 35 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

                          Severity
                          Category
                          Status
                          Source
                          Language