18F/analytics.usa.gov

View on GitHub

Showing 25 of 104 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/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

          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

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

          export default {
            // The realtime block is just `data.totals.active_visitors` formatted with commas
            realtime: renderBlock.loadAndRender().render((selection, data) => {
              const totals = data.data[0];
              selection.text(formatters.addCommas(+totals.active_visitors));
          Severity: Minor
          Found in js/lib/blocks.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 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/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/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/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/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/timeseries.js - About 2 hrs to fix

                    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/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

                    Method initialize has 14 arguments (exceeds 4 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)
                    Severity: Major
                    Found in _plugins/jekyll_page_generator.rb - About 1 hr to fix

                      Function pagination has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          pagination: function () {
                            var previousButtons = document.getElementsByClassName("previous-section");
                            var nextButtons = document.getElementsByClassName("next-section");
                      
                            var self = this;
                      Severity: Minor
                      Found in js/lib/touchpoints.js - About 1 hr to fix

                        Function formSuccess has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            formSuccess: function (e) {
                              // Clear the alert box
                              var formComponent = this.formComponent();
                              var alertElement = formComponent.querySelector(".fba-alert");
                              var alertElementBody = formComponent.getElementsByClassName("usa-alert__text")[0];
                        Severity: Minor
                        Found in js/lib/touchpoints.js - About 1 hr to fix

                          Method generate has 37 lines of code (exceeds 25 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 1 hr to fix

                            Function secondsToReadableTime has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function secondsToReadableTime(paramSeconds) {
                              const secondsInAYear = 31536000;
                              const secondsInADay = 86400;
                              const secondsInAnHour = 3600;
                              const secondsInAMinute = 60;
                            Severity: Minor
                            Found in js/lib/formatters.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language