18F/analytics.usa.gov

View on GitHub

Showing 190 of 190 total issues

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

                <p class="margin-y-2">
                  <a href="https://github.com/18F/analytics-reporter">
                    <img
                      src={`${siteDomain}/images/github-logo.svg`}
                      class="github-icon"
Severity: Major
Found in js/components/footer/Footer.js and 1 other location - About 1 hr to fix
js/components/footer/Footer.js on lines 107..116

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

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

                <p class="">
                  <a href="https://github.com/18F/analytics.usa.gov">
                    <img
                      src={`${siteDomain}/images/github-logo.svg`}
                      class="github-icon"
Severity: Major
Found in js/components/footer/Footer.js and 1 other location - About 1 hr to fix
js/components/footer/Footer.js on lines 117..126

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

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

    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

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

              const initHistoricalChart = async () => {
                const result = await d3
                  .select(ref.current)
                  .datum({
                    source: dataURL,
          Severity: Minor
          Found in js/components/main_charts/TopPagesHistorical.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 handleSubmit has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function handleSubmit(e) {
                  e.preventDefault();
                  const reportFormat = e.nativeEvent.submitter.value.toLowerCase();
                  setError(false);
              
              
              Severity: Minor
              Found in js/components/historical_data_download/HistoricalDataDownload.js - About 1 hr to fix

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

                        it("returns the expected data", () => {
                          expect(actual).toEqual(
                            mockData.map(({ notice, id, ...remaining }) => {
                              return {
                                ...remaining,
                Severity: Major
                Found in js/lib/__tests__/dap_api_data_formatter.spec.js and 1 other location - About 1 hr to fix
                js/lib/__tests__/dap_api_data_formatter.spec.js on lines 92..100

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

                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

                        it("returns the expected data with report mapped", () => {
                          expect(actual).toEqual(
                            mockData.map(({ notice, id, ...remaining }) => {
                              return {
                                ...remaining,
                Severity: Major
                Found in js/lib/__tests__/dap_api_data_formatter.spec.js and 1 other location - About 1 hr to fix
                js/lib/__tests__/dap_api_data_formatter.spec.js on lines 138..146

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

                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 initRealtimeChart has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const initRealtimeChart = async () => {
                      const result = await d3
                        .select(ref.current)
                        .datum({
                          source: dataURL,
                Severity: Minor
                Found in js/components/main_charts/TopPagesRealtime.js - 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/chart_helpers/formatters.js - About 1 hr to fix

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

                        const initSessions30DaysChart = async () => {
                          const result = await d3
                            .select(ref.current)
                            .datum({
                              source: reportURL,
                    Severity: Minor
                    Found in js/components/main_charts/Sessions30Days.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 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

                      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

                      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 js/lib/chart_helpers/__tests__/transformers.spec.js and 1 other location - About 1 hr to fix
                        js/lib/chart_helpers/__tests__/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

                        Severity
                        Category
                        Status
                        Source
                        Language