18F/analytics.usa.gov

View on GitHub

Showing 104 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

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

          checkEmail: function (form) {
            var emailItems = form.querySelectorAll('input[type="email"]');
            var questions = {};
            // Build a dictionary of questions which require an answer
            Array.prototype.forEach.call(emailItems, function (item) { questions[item.name] = item });
      Severity: Major
      Found in js/lib/touchpoints.js and 1 other location - About 1 day to fix
      js/lib/touchpoints.js on lines 273..291

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

      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

          checkPhone: function (form) {
            var phoneItems = form.querySelectorAll('input[type="tel"]');
            var questions = {};
            // Build a dictionary of questions which require an answer
            Array.prototype.forEach.call(phoneItems, function (item) { questions[item.name] = item });
      Severity: Major
      Found in js/lib/touchpoints.js and 1 other location - About 1 day to fix
      js/lib/touchpoints.js on lines 254..272

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

      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

      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

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

          describe("readableBigNumbers", () => {
            it("add a comma a number in the thousands", () => {
              assert.equal(formatters.readableBigNumber("1200"), "1,200");
            });
        
        
        Severity: Major
        Found in spec/formatters.spec.js and 1 other location - About 5 hrs to fix
        spec/formatters.spec.js on lines 5..21

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

        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

          describe("trimZeros", () => {
            it("should not do anything to a number that has no zeros", () => {
              assert.equal(formatters.trimZeroes("25"), "25");
            });
        
        
        Severity: Major
        Found in spec/formatters.spec.js and 1 other location - About 5 hrs to fix
        spec/formatters.spec.js on lines 55..71

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

        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

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

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

            describe("floatToPercent", () => {
              it("adds a percent sign and chops off the decimal of a float", () => {
                assert.equal(formatters.floatToPercent(12.0), "12%");
              });
          
          
          Severity: Major
          Found in spec/formatters.spec.js and 1 other location - About 3 hrs to fix
          spec/formatters.spec.js on lines 87..99

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

          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

            describe("formatHour", () => {
              it("returns the hour and a to a morning hour", () => {
                assert.equal(formatters.formatHour(11), "11a");
              });
          
          
          Severity: Major
          Found in spec/formatters.spec.js and 1 other location - About 3 hrs to fix
          spec/formatters.spec.js on lines 73..85

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

          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

            "top-pages-realtime": renderBlock
              .loadAndRender()
              .transform((d) => d.data)
              .on("render", (selection) => {
                selection
          Severity: Major
          Found in js/lib/blocks.js and 1 other location - About 3 hrs to fix
          js/lib/blocks.js on lines 261..289

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

          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

            "top-pages": renderBlock
              .loadAndRender()
              .transform((d) => d.data)
              .on("render", (selection) => {
                // turn the labels into links
          Severity: Major
          Found in js/lib/blocks.js and 1 other location - About 3 hrs to fix
          js/lib/blocks.js on lines 235..258

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

          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

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

                  Severity
                  Category
                  Status
                  Source
                  Language