volontariat/voluntary_proposition

View on GitHub

Showing 11 of 26 total issues

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

    Method voluntary_menu_options has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.voluntary_menu_options
          {
            organizations: {
              after_resource_has_many: Proc.new do |organization, options|
                organization.item :units, I18n.t('proposition_units.index.title'), organization_proposition_units_path(@organization) do |units|
    Severity: Minor
    Found in lib/voluntary_proposition/navigation.rb - About 2 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

    Method path_to has 51 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

      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 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_candidature_defaults(attributes)
              attributes[:user_id] ||= @me.id unless attributes[:user] || attributes[:user_id] || !@me
              attributes[:vacancy_id] ||= Vacancy.last.id unless attributes[:vacancy_id] || Vacancy.all.none?
              attributes[:offeror_id] ||= Vacancy.find(attributes[:vacancy_id]).project.user_id if attributes[:vacancy_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 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 set_vacancy_defaults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_vacancy_defaults(attributes)
              attributes[:user_id] ||= @me.id unless attributes[:user_id] || !@me
              attributes[:project_id] ||= Project.last.id unless attributes[:project_id] || Project.all.none?
            end
          Severity: Minor
          Found in dummy/features/step_definitions/vacancy_steps.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 set_project_defaults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_project_defaults(attributes)
              attributes[:user_id] ||= @me.id if @me && !attributes[:user_id]
              attributes[:product_id] ||= @product.id if @product && !attributes[:product_id]
              attributes[:area_ids] ||= [Area.last.id] if Area.any? && !attributes[:area_ids]
            end
          Severity: Minor
          Found in dummy/features/step_definitions/project_steps.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

          Severity
          Category
          Status
          Source
          Language