opengovernment/askthem

View on GitHub

Showing 154 of 154 total issues

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/person/widget.js and 2 other locations - About 1 day to fix
public/widgets/address/widget.js on lines 54..91
public/widgets/widget-builder/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 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/address/widget.js and 2 other locations - About 1 day to fix
public/widgets/person/widget.js on lines 54..91
public/widgets/widget-builder/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 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

File rails.validations.js has 617 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {
  var $, validateElement, validateForm, validatorsFor,
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  $ = jQuery;
Severity: Major
Found in app/assets/javascripts/rails.validations.js - About 1 day to fix

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

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

    Class PagesController has 41 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class PagesController < ApplicationController
      DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
      DEFAULT_MUNICIPALITY = "New York"
    
      skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
    Severity: Minor
    Found in app/controllers/pages_controller.rb - About 5 hrs to fix

      Function main has 125 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: Major
      Found in public/widgets/person/widget.js - About 5 hrs to fix

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

                  if (_ref = element.val(), __indexOf.call((function() {
                    var _i, _len, _ref1, _results;
                    _ref1 = options["in"];
                    _results = [];
                    for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        Severity: Major
        Found in app/assets/javascripts/rails.validations.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/rails.validations.js on lines 430..441

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

        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 (_ref = element.val(), __indexOf.call((function() {
                    var _i, _len, _ref1, _results;
                    _ref1 = options["in"];
                    _results = [];
                    for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
        Severity: Major
        Found in app/assets/javascripts/rails.validations.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/rails.validations.js on lines 399..410

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

        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/address/widget.js and 2 other locations - About 4 hrs to fix
        public/widgets/person/widget.js on lines 94..119
        public/widgets/widget-builder/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 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 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/person/widget.js and 2 other locations - About 4 hrs to fix
        public/widgets/address/widget.js on lines 94..119
        public/widgets/widget-builder/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

        Method add_attributes_to has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_attributes_to(person)
            unless person.read_attribute(:ocd_division_id)
              person.write_attribute(:ocd_division_id, ocd_division_id)
            end
        
        
        Severity: Minor
        Found in app/models/cached_official.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

        File pages_controller.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class PagesController < ApplicationController
          DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
          DEFAULT_MUNICIPALITY = "New York"
        
          skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
        Severity: Minor
        Found in app/controllers/pages_controller.rb - About 4 hrs to fix

          Method get has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

            def get(endpoint, params = {})
              begin
                result = JSON.parse(RestClient.get("http://api.votesmart.org/#{endpoint}", params: params.merge(key: @api_key, o: 'JSON')))
          
                if result['error']
          Severity: Minor
          Found in lib/project_vote_smart.rb - About 3 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 main has 91 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: Major
          Found in public/widgets/zip/widget.js - About 3 hrs to fix

            Class Person has 29 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Person
              include Mongoid::Document
            
              # authorization based on roles
              # i.e. a user.can_respond_as?(person) to answer questions
            Severity: Minor
            Found in app/models/person.rb - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language