opengovernment/askthem

View on GitHub

Showing 84 of 154 total issues

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

    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

        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

              Class QuestionsController has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class QuestionsController < ApplicationController
                before_filter :force_http
              
                inherit_resources
                belongs_to :jurisdiction, parent_class: Metadatum, finder: :find_by_abbreviation, param: :jurisdiction
              Severity: Minor
              Found in app/controllers/questions_controller.rb - About 3 hrs to fix

                File questions_controller.rb has 303 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class QuestionsController < ApplicationController
                  before_filter :force_http
                
                  inherit_resources
                  belongs_to :jurisdiction, parent_class: Metadatum, finder: :find_by_abbreviation, param: :jurisdiction
                Severity: Minor
                Found in app/controllers/questions_controller.rb - About 3 hrs to fix

                  Function main has 74 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/address/widget.js - About 2 hrs to fix

                    Function _placeholder_shim has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _placeholder_shim: function(config) {
                          function calcPositionCss(target)
                          {
                            var op = $(target).offsetParent().offset();
                            var ot = $(target).offset();
                    Severity: Major
                    Found in app/assets/javascripts/jquery.html5-placeholder-shim.js - About 2 hrs to fix

                      File cached_official.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      class CachedOfficial
                        include Mongoid::Document
                      
                        # The person's jurisdiction in askthem
                        belongs_to :metadatum, foreign_key: "state"
                      Severity: Minor
                      Found in app/models/cached_official.rb - About 2 hrs to fix

                        Method create has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def create
                            @question = Question.new(params[:question])
                            if @question.person_id.present?
                              @person = @question.person
                              @question.state = @person.state
                        Severity: Minor
                        Found in app/controllers/questions_controller.rb - 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 input has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            input: function(input) {
                              var $form, $input, binding, event, form, _ref;
                              $input = $(input);
                              form = input.form;
                              $form = $(form);
                        Severity: Major
                        Found in app/assets/javascripts/rails.validations.js - About 2 hrs to fix

                          Method create has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def create
                              person_id = params[:user].delete(:person_id)
                          
                              build_resource(sign_up_params)
                          
                          
                          Severity: Minor
                          Found in app/controllers/registrations_controller.rb - 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

                          Method show has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def show
                              @user = user_signed_in? ? current_user : User.new
                              if params[:code]
                                confirmed_question = Question.where(id: params[:id])
                                                     .where(confirm_code: params[:code]).first
                          Severity: Minor
                          Found in app/controllers/questions_controller.rb - 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

                          Method all has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def self.all
                              [ # In both OpenStates and VoteSmart:     # Additional VoteSmart subjects:
                                'Agriculture and Food',
                                'Business and Consumers',
                                'Civil Liberties and Civil Rights',     # Women
                          Severity: Major
                          Found in app/models/subject.rb - About 2 hrs to fix

                            Function uniqueness has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  uniqueness: function(element, options) {
                                    var data, key, message, name, scope_value, scoped_element, scoped_name, _ref;
                                    message = ClientSideValidations.validators.local.presence(element, options);
                                    if (message) {
                                      if (options.allow_blank === true) {
                            Severity: Major
                            Found in app/assets/javascripts/rails.validations.js - About 2 hrs to fix

                              Method create has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def create
                                  @question = Question.new(params[:question])
                                  if @question.person_id.present?
                                    @person = @question.person
                                    @question.state = @person.state
                              Severity: Major
                              Found in app/controllers/questions_controller.rb - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language