volontariat/voluntary_scholarship

View on GitHub

Showing 33 of 33 total issues

Method code has a Cognitive Complexity of 121 (exceeds 5 allowed). Consider refactoring.
Open

    def self.code
      Proc.new do |navigation|
        navigation.items do |primary|
          primary.dom_class = 'nav'
          
Severity: Minor
Found in lib/voluntary_scholarship/navigation.rb - About 2 days 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 165 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/20140306191343_create_schema.voluntary_engine.rb - About 6 hrs to fix

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

                unless (@team.new_record? rescue true)
                  teams.item :show, @team.name, scholarship_team_path(@team) do |team|
                    if can? :destroy, @team
                      team.item :destroy, I18n.t('general.destroy'), scholarship_team_path(@team), method: :delete, confirm: I18n.t('general.questions.are_you_sure')
                    end
    Severity: Major
    Found in lib/voluntary_scholarship/navigation.rb and 1 other location - About 3 hrs to fix
    lib/voluntary_scholarship/navigation.rb on lines 42..63

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

    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

                      unless (@iteration.new_record? rescue true)
                        iterations.item(
                          :show, @iteration.to_s, 
                          scholarship_iteration_path(@iteration) 
                        ) do |iteration|
    Severity: Major
    Found in lib/voluntary_scholarship/navigation.rb and 1 other location - About 3 hrs to fix
    lib/voluntary_scholarship/navigation.rb on lines 76..94

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

    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 code has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.code
          Proc.new do |navigation|
            navigation.items do |primary|
              primary.dom_class = 'nav'
              
    Severity: Major
    Found in lib/voluntary_scholarship/navigation.rb - About 3 hrs to fix

      Method path_to has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

        ActiveRecord::Schema.define(version: 20150819152545) 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 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'

            Consider simplifying this complex logical expression.
            Open

                    if user.present?
                      ability.can(:restful_actions, Scholarship::Team) {|team| team.new_record? || user.is_leader_of_scholarship_team?(team) }
                      
                      ability.can(:restful_actions, Scholarship::TeamMembership) do |membership| 
                        membership.new_record? || membership.user_id == user.id || user.is_leader_of_scholarship_team?(membership.team)
            Severity: Critical
            Found in lib/voluntary_scholarship/ability.rb - About 1 hr to fix

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

                create_table "list_items", force: :cascade do |t|
                  t.integer  "list_id",    limit: 4
                  t.integer  "user_id",    limit: 4
                  t.string   "thing_type", limit: 255
                  t.integer  "thing_id",   limit: 4
              Severity: Minor
              Found in dummy/db/schema.rb and 1 other location - About 55 mins to fix
              dummy/db/schema.rb on lines 218..225

              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

                create_table "scholarship_team_memberships", force: :cascade do |t|
                  t.integer  "team_id",    limit: 4
                  t.integer  "user_id",    limit: 4
                  t.integer  "roles",      limit: 4
                  t.text     "text",       limit: 65535
              Severity: Minor
              Found in dummy/db/schema.rb and 1 other location - About 55 mins to fix
              dummy/db/schema.rb on lines 109..116

              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

              Method accepted_team_membership_for_team_roles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def accepted_team_membership_for_team_roles
                    team_roles = roles.select{|role| TeamMembership::ROLES.include?(role) }
                    
                    return unless team_roles.any?
                    
              Severity: Minor
              Found in app/models/scholarship/iteration_participation.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 58..64

              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 "arguments", force: :cascade do |t|
                  t.string   "argumentable_type", limit: 255
                  t.integer  "argumentable_id",   limit: 4
                  t.integer  "topic_id",          limit: 4
                  t.string   "value",             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 128..134

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

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

                def update
                  if params[:scholarship_team_membership][:roles].present? && !can_update_scholarship_team_membership_roles?(@team_membership)
                    raise CanCan::AccessDenied  
                  end
                  
              Severity: Minor
              Found in app/controllers/scholarship/team_memberships_controller.rb and 1 other location - About 30 mins to fix
              app/controllers/scholarship/iteration_participations_controller.rb on lines 39..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 32.

              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

                def update
                  if params[:scholarship_iteration_participation][:roles].present? && !can_update_scholarship_iteration_participation_roles?(@iteration_participation)
                    raise CanCan::AccessDenied  
                  end
                  
              app/controllers/scholarship/team_memberships_controller.rb on lines 37..46

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

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

                def find_program
                  @program = case action_name
                  when 'new' then 
                    @organization = Organization.friendly.find(params[:organization_id]) if params[:organization_id].present?
                    @organization.present? ? @organization.scholarship_programs.new : Scholarship::Program.new
              Severity: Minor
              Found in app/controllers/scholarship/programs_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