18F/analytics.usa.gov

View on GitHub

Showing 104 of 104 total issues

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

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

      describe("formatURL", () => {
        it("returns a clean url without a port and the site suffix", () => {
          assert.equal(
            formatters.formatURL("https://www.irs.gov:8443/cool-change"),
            "www.irs.gov",
    Severity: Major
    Found in spec/formatters.spec.js and 1 other location - About 2 hrs to fix
    spec/formatters.spec.js on lines 114..125

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

    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("formatFile", () => {
        it("returns the file name from a given url", () => {
          assert.equal(
            formatters.formatFile("https://www.irs.gov:8443/ds82.pdf"),
            "/ds82.pdf",
    Severity: Major
    Found in spec/formatters.spec.js and 1 other location - About 2 hrs to fix
    spec/formatters.spec.js on lines 101..112

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

    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

    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

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

              textareas.forEach(function (textarea) {
                if (textarea.getAttribute("maxlength") != '0' && textarea.getAttribute("maxlength") != '10000') {
                  textarea.addEventListener("keyup", self.textCounter);
                }
              });
        Severity: Major
        Found in js/lib/touchpoints.js and 1 other location - About 1 hr to fix
        js/lib/touchpoints.js on lines 69..73

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

        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

              textFields.forEach(function (textField) {
                if (textField.getAttribute("maxlength") != '0' && textField.getAttribute("maxlength") != '10000') {
                  textField.addEventListener("keyup", self.textCounter);
                }
              });
        Severity: Major
        Found in js/lib/touchpoints.js and 1 other location - About 1 hr to fix
        js/lib/touchpoints.js on lines 62..66

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

        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

        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

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

                        if (document.getElementsByClassName("fba-modal")[0]) {
                          document.getElementsByClassName("fba-modal")[0].scrollTo(0, 0);
                        } else {
                          window.scrollTo(0, 0);
                        }
              Severity: Major
              Found in js/lib/touchpoints.js and 1 other location - About 1 hr to fix
              js/lib/touchpoints.js on lines 603..607

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

              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

                        if (document.getElementsByClassName("fba-modal")[0]) {
                          document.getElementsByClassName("fba-modal")[0].scrollTo(0, 0);
                        } else {
                          window.scrollTo(0, 0);
                        }
              Severity: Major
              Found in js/lib/touchpoints.js and 1 other location - About 1 hr to fix
              js/lib/touchpoints.js on lines 579..583

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

              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

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

                  loadHtml: function () {
              
                    this.dialogEl = document.createElement('div');
                    this.dialogEl.setAttribute("hidden", true);
                    this.dialogEl.setAttribute('class', 'fba-modal');
              Severity: Minor
              Found in js/lib/touchpoints.js - About 1 hr to fix

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

                      const proportionArrayResult = [
                        { key: "bob", value: 1000, proportion: 76.8 },
                        { key: "harry", value: 300, proportion: 23.0 },
                        { key: "Other", proportion: 0.004, children: [] },
                      ];
                Severity: Major
                Found in spec/transformers.spec.js and 1 other location - About 1 hr to fix
                spec/transformers.spec.js on lines 107..111

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

                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

                      const resultsArray = [
                        { key: "bob", value: 1000, proportion: 76.92189350933063 },
                        { key: "harry", value: 300, proportion: 23.07656805279919 },
                        { key: "Other", proportion: 0.0015384378701866124, children: [] },
                      ];
                Severity: Major
                Found in spec/transformers.spec.js and 1 other location - About 1 hr to fix
                spec/transformers.spec.js on lines 93..97

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

                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

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

                  const block = function (selection) {
                    selection
                      .each(load)
                      .filter(function (d) {
                        d.refresh = +this.getAttribute("data-refresh");
                Severity: Minor
                Found in js/lib/renderblock.js - About 1 hr to fix

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

                      d3.selectAll(".download-data").on("click", function () {
                        const link = this.href;
                        const eventText = this.text;
                        ga("send", "event", "Download Data", link, eventText);
                      });
                  Severity: Major
                  Found in js/lib/eventhandler.js and 3 other locations - About 1 hr to fix
                  js/lib/eventhandler.js on lines 11..15
                  js/lib/eventhandler.js on lines 17..21
                  js/lib/eventhandler.js on lines 23..27

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

                  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 4 locations. Consider refactoring.
                  Open

                      d3.selectAll(".external-link").on("click", function () {
                        const link = this.href;
                        const eventText = this.text;
                        ga("send", "event", "External Link", link, eventText);
                      });
                  Severity: Major
                  Found in js/lib/eventhandler.js and 3 other locations - About 1 hr to fix
                  js/lib/eventhandler.js on lines 5..9
                  js/lib/eventhandler.js on lines 17..21
                  js/lib/eventhandler.js on lines 23..27

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language