opengovernment/askthem

View on GitHub
public/widgets/widget-builder/widget.js

Summary

Maintainability
F
5 days
Test Coverage

Function main has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function main() {
    jQuery(document).ready(function($) {
      // We can use jQuery here

      // load css, only if it hasn't been loaded
Severity: Minor
Found in public/widgets/widget-builder/widget.js - About 1 hr to fix

    Function addMetaTags has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function addMetaTags(tagId, options) {
        this._createMetaTag = function(name, content) {
          var metaTag = jQuery("<meta>", {
            name: name,
            content: content
    Severity: Minor
    Found in public/widgets/widget-builder/widget.js - About 1 hr to fix

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

        function addMetaTags(tagId, options) {
          this._createMetaTag = function(name, content) {
            var metaTag = jQuery("<meta>", {
              name: name,
              content: content
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 2 other locations - About 1 day to fix
      public/widgets/address/widget.js on lines 54..91
      public/widgets/person/widget.js on lines 54..91

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

      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

        if (window.jQuery === undefined || window.jQuery.fn.jquery !== '2.1.3') {
          var script_tag = document.createElement('script');
          script_tag.setAttribute("type","text/javascript");
          script_tag.setAttribute("src",
                                  "http://code.jquery.com/jquery-2.1.3.min.js");
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 3 other locations - About 1 day to fix
      public/widgets/address/widget.js on lines 15..35
      public/widgets/person/widget.js on lines 15..35
      public/widgets/zip/widget.js on lines 15..35

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

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

        function appFromConcoction(tagId) {
          // TODO: make sure that tagId is valid for our needs
          var appConcoction;
      
          // in dev, loading fails in chrome with security issue, due to CORs no in pow
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 2 other locations - About 4 hrs to fix
      public/widgets/address/widget.js on lines 94..119
      public/widgets/person/widget.js on lines 94..119

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

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

                if(paramsDiv) {
                  if (jQuery(paramsDiv).find('.intro-explanatory').length > 0) questionSummary = jQuery(paramsDiv).find('.intro-explanatory').html();
                } else if (typeof jQuery(this).data('intro-explanatory') !== "undefined") {
                  explanatory = jQuery(this).data('intro-explanatory');
                }
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 24 other locations - About 3 hrs to fix
      public/widgets/address/widget.js on lines 198..202
      public/widgets/address/widget.js on lines 206..210
      public/widgets/address/widget.js on lines 214..218
      public/widgets/address/widget.js on lines 222..226
      public/widgets/address/widget.js on lines 230..234
      public/widgets/person/widget.js on lines 189..193
      public/widgets/person/widget.js on lines 197..201
      public/widgets/person/widget.js on lines 205..209
      public/widgets/person/widget.js on lines 212..216
      public/widgets/person/widget.js on lines 219..223
      public/widgets/person/widget.js on lines 226..230
      public/widgets/person/widget.js on lines 233..237
      public/widgets/person/widget.js on lines 240..244
      public/widgets/person/widget.js on lines 247..251
      public/widgets/person/widget.js on lines 254..258
      public/widgets/person/widget.js on lines 262..266
      public/widgets/person/widget.js on lines 270..274
      public/widgets/person/widget.js on lines 278..282
      public/widgets/widget-builder/widget.js on lines 190..194
      public/widgets/zip/widget.js on lines 133..137
      public/widgets/zip/widget.js on lines 144..148
      public/widgets/zip/widget.js on lines 155..159
      public/widgets/zip/widget.js on lines 166..170
      public/widgets/zip/widget.js on lines 177..181

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

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

                if(paramsDiv) {
                  if (jQuery(paramsDiv).find('.intro-headline').length > 0) headline = jQuery(paramsDiv).find('.intro-headline').html();
                } else if (typeof jQuery(this).data('intro-headline') !== "undefined") {
                  headline = jQuery(this).data('intro-headline');
                }
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 24 other locations - About 3 hrs to fix
      public/widgets/address/widget.js on lines 198..202
      public/widgets/address/widget.js on lines 206..210
      public/widgets/address/widget.js on lines 214..218
      public/widgets/address/widget.js on lines 222..226
      public/widgets/address/widget.js on lines 230..234
      public/widgets/person/widget.js on lines 189..193
      public/widgets/person/widget.js on lines 197..201
      public/widgets/person/widget.js on lines 205..209
      public/widgets/person/widget.js on lines 212..216
      public/widgets/person/widget.js on lines 219..223
      public/widgets/person/widget.js on lines 226..230
      public/widgets/person/widget.js on lines 233..237
      public/widgets/person/widget.js on lines 240..244
      public/widgets/person/widget.js on lines 247..251
      public/widgets/person/widget.js on lines 254..258
      public/widgets/person/widget.js on lines 262..266
      public/widgets/person/widget.js on lines 270..274
      public/widgets/person/widget.js on lines 278..282
      public/widgets/widget-builder/widget.js on lines 198..202
      public/widgets/zip/widget.js on lines 133..137
      public/widgets/zip/widget.js on lines 144..148
      public/widgets/zip/widget.js on lines 155..159
      public/widgets/zip/widget.js on lines 166..170
      public/widgets/zip/widget.js on lines 177..181

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

      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

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

        function addCssLinksIfNecessary(cssUrls) {
          jQuery.each(cssUrls, function(key, value) {
            var cssSelector = "link[href='"+ value + "']";
      
            if (!jQuery(cssSelector).length) {
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 2 other locations - About 3 hrs to fix
      public/widgets/address/widget.js on lines 135..149
      public/widgets/person/widget.js on lines 135..149

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

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

        function addJSIfNecessary(jsUrls) {
          jQuery.each(jsUrls, function(key, value) {
            AskThemWidgetBuilderWidget.jsNecessaryToComplete++;
      
            jQuery.ajax({
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 2 other locations - About 2 hrs to fix
      public/widgets/address/widget.js on lines 121..133
      public/widgets/person/widget.js on lines 121..133

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

      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

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

                jQuery('div.at-widget-attributes').each(function () {
                  var associatedTagId = jQuery(this).data('tag-id');
                  if (typeof associatedTagId !== "undefined" && associatedTagId === tagId) {
                    paramsDiv = this;
                  }
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 3 other locations - About 1 hr to fix
      public/widgets/address/widget.js on lines 181..186
      public/widgets/person/widget.js on lines 181..186
      public/widgets/zip/widget.js on lines 113..118

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

      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

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

                if (jQuery(this).data('tag-id') && jQuery(this).data('tag-id').length > 0) tagId = jQuery(this).data('tag-id');
      Severity: Major
      Found in public/widgets/widget-builder/widget.js and 3 other locations - About 1 hr to fix
      public/widgets/address/widget.js on lines 176..176
      public/widgets/person/widget.js on lines 176..176
      public/widgets/zip/widget.js on lines 108..108

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

      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

      There are no issues that match your filters.

      Category
      Status