volontariat/voluntary_feedback

View on GitHub

Showing 33 of 33 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/20150825160814_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 259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    ActiveRecord::Schema.define(version: 20150825160838) 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 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def up
          if Product::Feedback.first
          else
            Product::Feedback.create(name: 'Feedback', 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 path_to has 37 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 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_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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def update
                  resource = Community.friendly.find(params[:feedback][:community_slug]).feedbacks.friendly.find(params[:id])
                  
                  raise CanCan::AccessDenied unless resource.user_id == current_user.id
                  
              Severity: Minor
              Found in app/controllers/voluntary/api/v1/feedbacks_controller.rb - About 45 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

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

                create_table "mongo_db_documents", force: :cascade do |t|
                  t.string   "mongo_db_object_id", limit: 255
                  t.string   "klass_name",         limit: 255
                  t.string   "name",               limit: 255
                  t.string   "slug",               limit: 255
              Severity: Minor
              Found in dummy/db/schema.rb and 1 other location - About 40 mins to fix
              dummy/db/schema.rb on lines 91..97

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

              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

                create_table "communities", force: :cascade do |t|
                  t.integer  "organization_id", limit: 4
                  t.string   "name",            limit: 255
                  t.string   "slug",            limit: 255
                  t.text     "text",            limit: 65535
              Severity: Minor
              Found in dummy/db/schema.rb and 1 other location - About 40 mins to fix
              dummy/db/schema.rb on lines 181..187

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

              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

              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

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

                def up
                  add_column :vacancies, :resource_type, :string
                  add_column :vacancies, :resource_id, :integer
                  
                  if (Product::Recruiting rescue nil)

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

                def create
                  resource = Community.friendly.find(params[:feedback][:community_slug]).feedbacks.new params[:feedback]
                  resource.user_id = current_user.id
                  resource.save
                  resource.category_ids = params[:feedback][:category_ids] || [] if resource.persisted?
              Severity: Minor
              Found in app/controllers/voluntary/api/v1/feedbacks_controller.rb - About 25 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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def destroy
                  resource = Reply.find(params[:id])
                  
                  raise CanCan::AccessDenied unless resource.user_id == current_user.id
                  
              Severity: Minor
              Found in app/controllers/voluntary/api/v1/replies_controller.rb - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def update
                  community = Community.friendly.find(params[:community_category][:community_slug])
                  
                  raise CanCan::AccessDenied unless community.organization.user_id == current_user.id
                  
              Severity: Minor
              Found in app/controllers/voluntary/api/v1/community_categories_controller.rb - About 25 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 down has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def down
                  add_column :vacancies, :user_id, :integer
                  
                  if (Product::Recruiting rescue nil)
                    Vacancy.where('resource_type = "User"').update_all('user_id = resource_id')

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

                def destroy
                  community = Community.friendly.find(params[:community_slug])
                  
                  raise CanCan::AccessDenied unless community.organization.user_id == current_user.id
                  
              Severity: Minor
              Found in app/controllers/voluntary/api/v1/community_categories_controller.rb - About 25 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