volontariat/voluntary_classified_advertisement

View on GitHub

Showing 31 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

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

                  create_table 'vacancies', force: true do |t|
                    t.string   'type'
                    t.integer  'project_id'
                    t.integer  'offeror_id'
                    t.integer  'author_id'
            dummy/db/migrate/20151002121508_add_recruiting.voluntary_recruiting_engine.rb on lines 10..24

            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

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

                  create_table "vacancies", force: true do |t|
                    t.string   "type"
                    t.integer  "project_id"
                    t.integer  "offeror_id"
                    t.integer  "author_id"
            dummy/db/migrate/20151002121502_drop_recruiting_unless_recruiting_plugin_present.voluntary_engine.rb on lines 15..29

            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

            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

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

                  create_table 'candidatures', force: true do |t|
                    t.integer  'vacancy_id'
                    t.integer  'offeror_id'
                    t.string   'name'
                    t.string   'slug'
            dummy/db/migrate/20151002121508_add_recruiting.voluntary_recruiting_engine.rb on lines 35..45

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

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

                  create_table "candidatures", force: true do |t|
                    t.integer  "vacancy_id"
                    t.integer  "offeror_id"
                    t.string   "name"
                    t.string   "slug"
            dummy/db/migrate/20151002121502_drop_recruiting_unless_recruiting_plugin_present.voluntary_engine.rb on lines 38..48

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

            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

            Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
              with_scope(parent) do
                field = find_field(field)
                field_value = (field.tag_name == 'textarea') ? field.text : field.value
                if field_value.respond_to? :should_not
            Severity: Minor
            Found in dummy/features/step_definitions/web_steps.rb and 1 other location - About 35 mins to fix
            dummy/features/step_definitions/web_steps.rb on lines 158..165

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

            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

            Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
              with_scope(parent) do
                field = find_field(field)
                field_value = (field.tag_name == 'textarea') ? field.text : field.value
                if field_value.respond_to? :should
            Severity: Minor
            Found in dummy/features/step_definitions/web_steps.rb and 1 other location - About 35 mins to fix
            dummy/features/step_definitions/web_steps.rb on lines 170..177

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

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

            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

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

            Then /^I should see the following products:$/ do |expected_table|
              rows = find('table').all('tr')
              table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
              expected_table.diff!(table)
            Severity: Minor
            Found in dummy/features/step_definitions/product_steps.rb and 4 other locations - About 20 mins to fix
            dummy/features/step_definitions/area_steps.rb on lines 7..10
            dummy/features/step_definitions/candidature_steps.rb on lines 34..37
            dummy/features/step_definitions/story_steps.rb on lines 29..32
            dummy/features/step_definitions/vacancy_steps.rb on lines 32..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 27.

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

            Then /^I should see the following candidatures:$/ do |expected_table|
              rows = find('table').all('tr')
              table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
              expected_table.diff!(table)
            Severity: Minor
            Found in dummy/features/step_definitions/candidature_steps.rb and 4 other locations - About 20 mins to fix
            dummy/features/step_definitions/area_steps.rb on lines 7..10
            dummy/features/step_definitions/product_steps.rb on lines 11..14
            dummy/features/step_definitions/story_steps.rb on lines 29..32
            dummy/features/step_definitions/vacancy_steps.rb on lines 32..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 27.

            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

            Severity
            Category
            Status
            Source
            Language