volontariat/voluntary_classified_advertisement

View on GitHub

Showing 12 of 31 total issues

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/20130806125714_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

    File schema.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    ActiveRecord::Schema.define(version: 20151029170707) do
    
      create_table "areas", force: :cascade do |t|
        t.string   "ancestry",       limit: 255
        t.integer  "ancestry_depth", limit: 4,   default: 0
    Severity: Minor
    Found in dummy/db/schema.rb - About 2 hrs to fix

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

        def up
          if product = Product.where(name: 'Recruiting').first
          else
            Product.create(name: 'Recruiting', text: 'Dummy')
          end

        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 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 set_candidature_defaults has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def set_candidature_defaults(attributes)
                unless attributes[:resource] || attributes[:resource_id] || !@me
                  attributes[:resource_type] ||= 'User'
                  attributes[:resource_id] ||= @me.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 sign_up has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def sign_up(current_user_id, amount = nil)
                amount = vacancy.resource_type == 'User' ? 1 : amount
                user_candidature = vacancy.candidatures.where(user_id: current_user_id).first
                
                if amount == user_candidature.try(:amount)
            Severity: Minor
            Found in app/models/product/classified_advertisement/task.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 set_vacancy_defaults has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def set_vacancy_defaults(attributes)
                unless attributes[:resource] || attributes[:resource_id] || !@me
                  attributes[:resource_type] ||= 'User'
                  attributes[:resource_id] ||= @me.id 
                end
            Severity: Minor
            Found in dummy/features/step_definitions/vacancy_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

            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

            Method up has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def up
                Product.each do |product|
                  next if product.klass_name.present?
                  
                  if product.name == 'Product'

            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 up has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def up
                if product = Product.where(name: 'Recruiting').first
                else
                  Product.create(name: 'Recruiting', text: 'Dummy')
                end

            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