volontariat/voluntary_scholarship

View on GitHub

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

    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

              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

              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