volontariat/voluntary_ranking

View on GitHub

Showing 36 of 117 total issues

File ember-data.js has 4359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Version: v0.14
// Last commit: d9cd270 (2013-08-31 17:12:14 -0700)


(function() {
Severity: Major
Found in ember-data.js - About 1 wk to fix

    Method up has 164 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def up
        MongoDatabaseCleaner.clean
        
        create_table :users do |t|
          t.string :name
    Severity: Major
    Found in dummy/db/migrate/20130814161240_create_schema.voluntary_engine.rb - About 6 hrs to fix

      Method create_from_table has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_from_table(model_name, table, extra = {})
          factory_name = model_name.gsub(/\W+/, '_').downcase.singularize.to_sym
          is_singular = model_name.to_s.singularize == model_name.to_s
          
          hashes = if is_singular
      Severity: Minor
      Found in dummy/features/step_definitions/factory_steps.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

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

        def self.position_for_user_by_stars(user_id, ranking_id, user_ranking_item_id, stars)
          ranking_items = where(user_id: user_id, ranking_id: ranking_id)
          ranking_items_count = ranking_items.count
          ranking_items = ranking_items.where('id <> ?', user_ranking_item_id) if user_ranking_item_id.present?
          
      Severity: Minor
      Found in app/models/user_ranking_item.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 path_to has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def path_to(page_name)
          case page_name
      
          when /^the home\s?page$/
            '/'
      Severity: Minor
      Found in dummy/features/support/paths.rb - About 1 hr to fix

        Method down has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def down
            unless (Product::Recruiting rescue nil)
              create_table 'vacancies', force: true do |t|
                t.string   'type'
                t.integer  'project_id'

          Method copy_validation_errors_from_ranking_item has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def copy_validation_errors_from_ranking_item
              return if self.ranking_item.blank? || self.ranking_item.valid?
              
              self.ranking_item.errors.each do |field, ranking_item_errors| 
                ranking_item_errors = [ranking_item_errors] unless ranking_item_errors.is_a?(Array)
          Severity: Minor
          Found in app/models/user_ranking_item.rb - 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

          Function _debugInfo has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _debugInfo: function() {
              var attributes = ['id'],
                  relationships = { belongsTo: [], hasMany: [] },
                  expensiveProperties = [];
          
          
          Severity: Minor
          Found in ember-data.js - About 1 hr to fix

            Method create_from_table has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create_from_table(model_name, table, extra = {})
                factory_name = model_name.gsub(/\W+/, '_').downcase.singularize.to_sym
                is_singular = model_name.to_s.singularize == model_name.to_s
                
                hashes = if is_singular
            Severity: Minor
            Found in dummy/features/step_definitions/factory_steps.rb - About 1 hr to fix

              Method up has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def up
                  Product::Ranking.create(name: 'Ranking', text: 'Ranking')
                  
                  create_table :rankings, force:  true do |t|
                    t.string :adjective # best

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

                  findMany: function(type, idsOrReferencesOrOpaque, record, relationship) {
                    // 1. Determine which of the client ids need to be loaded
                    // 2. Create a new ManyArray whose content is ALL of the clientIds
                    // 3. Decrement the ManyArray's counter by the number of loaded clientIds
                    // 4. Put the ManyArray into our bookkeeping data structure, keyed on
                Severity: Minor
                Found in ember-data.js - About 1 hr to fix

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

                    inverseFor: function(name) {
                      var inverseType = this.typeForRelationship(name);
                  
                      if (!inverseType) { return null; }
                  
                  
                  Severity: Minor
                  Found in ember-data.js - About 1 hr to fix

                    Method find_or_create_by_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.find_or_create_by_params(params)
                        attributes = (params[:user_ranking_item] || params[:ranking_item] || params).clone
                        attributes.symbolize_keys! unless params.is_a?(ActiveSupport::HashWithIndifferentAccess)
                        
                        if attributes[:ranking_id].present? then Ranking.find(attributes[:ranking_id])
                    Severity: Minor
                    Found in app/models/ranking.rb - 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

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

                    DS.RelationshipChangeAdd.prototype.sync = function() {
                      var secondRecordName = this.getSecondRecordName(),
                          firstRecordName = this.getFirstRecordName(),
                          firstRecord = this.getFirstRecord(),
                          secondRecord = this.getSecondRecord();
                    Severity: Minor
                    Found in ember-data.js - About 1 hr to fix

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

                      DS.RelationshipChangeRemove.prototype.sync = function() {
                        var secondRecordName = this.getSecondRecordName(),
                            firstRecordName = this.getFirstRecordName(),
                            firstRecord = this.getFirstRecord(),
                            secondRecord = this.getSecondRecord();
                      Severity: Minor
                      Found in ember-data.js - About 1 hr to fix

                        Function ajax has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          ajax: function(url, type, hash) {
                            var adapter = this;
                        
                            return new Ember.RSVP.Promise(function(resolve, reject) {
                              hash = hash || {};
                        Severity: Minor
                        Found in ember-data.js - About 1 hr to fix

                          Method set_candidature_defaults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def set_candidature_defaults(attributes)
                              attributes[:user_id] ||= @me.id unless attributes[:user] || attributes[:user_id] || !@me
                              attributes[:vacancy_id] ||= Vacancy.last.id unless attributes[:vacancy_id] || Vacancy.all.none?
                              attributes[:offeror_id] ||= Vacancy.find(attributes[:vacancy_id]).project.user_id if attributes[:vacancy_id]
                            end
                          Severity: Minor
                          Found in dummy/features/step_definitions/candidature_steps.rb - 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 index has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def index
                              options = {}
                              
                              if ranking.present?
                                options[:json] = if params[:user_id].present? || params[:user_name].present?
                          Severity: Minor
                          Found in app/controllers/api/v1/user_ranking_items_controller.rb - About 1 hr to fix

                            Function belongsTo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            DS.belongsTo = function(type, options) {
                              Ember.assert("The first argument DS.belongsTo must be a model type or string, like DS.belongsTo(App.Person)", !!type && (typeof type === 'string' || DS.Model.detect(type)));
                            
                              options = options || {};
                            
                            
                            Severity: Minor
                            Found in ember-data.js - About 1 hr to fix

                              Method set_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def set_value(hash, attribute)
                                  value = hash[attribute]
                                  
                                  if value.match '@' 
                                    if eval(value)
                              Severity: Minor
                              Found in dummy/features/step_definitions/factory_steps.rb - About 55 mins 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

                              Severity
                              Category
                              Status
                              Source
                              Language