18F/analytics.usa.gov

View on GitHub

Showing 35 of 190 total issues

Function FBAform has 535 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function FBAform(d, N) {
  return {
    formId: "15ca967f",
    formComponent: function () {
      return document.querySelector("[data-touchpoints-form-id='" + this.formId + "']")
Severity: Major
Found in js/lib/touchpoints.js - About 2 days to fix

    Function FBAform has a Cognitive Complexity of 129 (exceeds 5 allowed). Consider refactoring.
    Open

    function FBAform(d, N) {
      return {
        formId: "15ca967f",
        formComponent: function () {
          return document.querySelector("[data-touchpoints-form-id='" + this.formId + "']")
    Severity: Minor
    Found in js/lib/touchpoints.js - About 2 days 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

    File touchpoints.js has 544 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
      This JS is included directly from the touchpoints app.  Included here to
      avoid writing unsafe content security policy allowances just for touchpoints.
      Minor changes were made to the original source to avoid inline styles.
    
    
    Severity: Major
    Found in js/lib/touchpoints.js - About 1 day to fix

      Method initialize has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(site, base, index_files, dir, dir_expr, page_data_prefix, data, name, name_expr, title, title_expr, template, extension, debug)
            @site = site
            @base = base
      
            if debug
      Severity: Minor
      Found in _plugins/jekyll_page_generator.rb - About 6 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 buildtimeSeries has 139 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function buildtimeSeries() {
        let series = function (d) {
          return [d];
        };
        let bars = function (d) {
      Severity: Major
      Found in js/lib/chart_helpers/timeseries.js - About 5 hrs to fix

        `` has 37 functions (exceeds 20 allowed). Consider refactoring.
        Open

          return {
            formId: "15ca967f",
            formComponent: function () {
              return document.querySelector("[data-touchpoints-form-id='" + this.formId + "']")
            },
        Severity: Minor
        Found in js/lib/touchpoints.js - About 4 hrs to fix

          File DataDownloads.js has 368 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React from "react";
          import PropTypes from "prop-types";
          
          /**
           * Creates tables with download links for many of the reports that are available
          Severity: Minor
          Found in js/components/data_downloads/DataDownloads.js - About 4 hrs to fix

            File HistoricalDataDownload.js has 359 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, { useState } from "react";
            import PropTypes from "prop-types";
            import { isFuture, parse } from "date-fns";
            import { mkConfig, generateCsv } from "export-to-csv";
            import DapApiService from "../../lib/dap_api_service";
            Severity: Minor
            Found in js/components/historical_data_download/HistoricalDataDownload.js - About 4 hrs to fix

              Method generate has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

                  def generate(site)
                    # page_gen-dirs is a global option which determines whether we want to
                    # generate index pages (name/index.html) or HTML files (name.html) for
                    # all sets
                    index_files = site.config['page_gen-dirs'] == true
              Severity: Minor
              Found in _plugins/jekyll_page_generator.rb - 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

              File dap_api_service.spec.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { lightFormat, startOfToday } from "date-fns";
              import DapApiService from "../dap_api_service";
              import ApiDataItemFactory from "../../../spec/factories/api_data_item";
              
              describe("DapApiService", () => {
              Severity: Minor
              Found in js/lib/__tests__/dap_api_service.spec.js - About 3 hrs to fix

                Method initialize has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize(site, base, index_files, dir, dir_expr, page_data_prefix, data, name, name_expr, title, title_expr, template, extension, debug)
                      @site = site
                      @base = base
                
                      if debug
                Severity: Major
                Found in _plugins/jekyll_page_generator.rb - About 2 hrs to fix

                  Function initRealtimeCountriesChart has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const initRealtimeCountriesChart = async () => {
                        // Create countries chart
                        await d3
                          .select(countriesRef.current)
                          .datum({
                  Severity: Major
                  Found in js/components/main_charts/TopCountriesRealtime.js - About 2 hrs to fix

                    Function loadAndRender has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function loadAndRender() {
                      let url = function (d) {
                        return d && d.source;
                      };
                    
                    
                    Severity: Major
                    Found in js/lib/chart_helpers/renderblock.js - About 2 hrs to fix

                      Function barChart has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export default function barChart() {
                        let bars = function (d) {
                          return d;
                        };
                      
                      
                      Severity: Major
                      Found in js/lib/chart_helpers/barchart.js - About 2 hrs to fix

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

                        export default function buildtimeSeries() {
                          let series = function (d) {
                            return [d];
                          };
                          let bars = function (d) {
                        Severity: Minor
                        Found in js/lib/chart_helpers/timeseries.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 loadAndRender has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function loadAndRender() {
                          let url = function (d) {
                            return d && d.source;
                          };
                        
                        
                        Severity: Minor
                        Found in js/lib/chart_helpers/renderblock.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 timeSeries has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          const timeSeries = function (svg) {
                            const right = width - margin.right;
                            const bottom = height - margin.bottom;
                        
                            yScale.range([bottom, margin.top]);
                        Severity: Major
                        Found in js/lib/chart_helpers/timeseries.js - About 2 hrs to fix

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

                          function HistoricalDataDownloads({ apiURL, mainAgencyName, agencies }) {
                            const parsedAgencies = JSON.parse(agencies).map(({ name, slug }) => {
                              return { name, value: slug };
                            });
                            const apiReports = [
                          Severity: Minor
                          Found in js/components/historical_data_download/HistoricalDataDownload.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 barChart has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export default function barChart() {
                            let bars = function (d) {
                              return d;
                            };
                          
                          
                          Severity: Minor
                          Found in js/lib/chart_helpers/barchart.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 initTopDownloads has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              const initTopDownloads = async () => {
                                const result = await d3
                                  .select(ref.current)
                                  .datum({
                                    source: reportURL,
                          Severity: Minor
                          Found in js/components/main_charts/TopDownloads.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language