volontariat/voluntary_translation

View on GitHub

Showing 30 of 30 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/20131009114502_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 path_to has 45 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 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 initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def initialize(user, options = {})
              controller_namespace = options[:controller_namespace] || ""
              project = options[:project] || nil
              
              alias_action :index, :show, :autocomplete, :parents, :childs, :tree, to: :read
          Severity: Minor
          Found in dummy/app/models/ability.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_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 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

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

              def name_valid?
                return unless name_changed?
                
                if name.present?
                  if Task.where(name: name, story_id: story_id, output_language: output_language).any?
            Severity: Minor
            Found in app/models/product/translation/task.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 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 2 locations. Consider refactoring.
            Open

            Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
              regexp = Regexp.new(regexp)
            
              if page.respond_to? :should
                page.should have_no_xpath('//*', :text => regexp)
            Severity: Minor
            Found in dummy/features/step_definitions/web_steps.rb and 1 other location - About 20 mins to fix
            dummy/features/step_definitions/web_steps.rb on lines 130..136

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

            Then /^I should see the following vacancies:$/ 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: Major
            Found in dummy/features/step_definitions/vacancy_steps.rb and 6 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 30..33
            dummy/features/step_definitions/product_steps.rb on lines 11..14
            dummy/features/step_definitions/project_steps.rb on lines 19..22
            dummy/features/step_definitions/story_steps.rb on lines 29..32
            dummy/features/step_definitions/task_steps.rb on lines 25..28

            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 7 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: Major
            Found in dummy/features/step_definitions/candidature_steps.rb and 6 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/project_steps.rb on lines 19..22
            dummy/features/step_definitions/story_steps.rb on lines 29..32
            dummy/features/step_definitions/task_steps.rb on lines 25..28
            dummy/features/step_definitions/vacancy_steps.rb on lines 28..31

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

            Then /^I should see the following areas:$/ 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: Major
            Found in dummy/features/step_definitions/area_steps.rb and 6 other locations - About 20 mins to fix
            dummy/features/step_definitions/candidature_steps.rb on lines 30..33
            dummy/features/step_definitions/product_steps.rb on lines 11..14
            dummy/features/step_definitions/project_steps.rb on lines 19..22
            dummy/features/step_definitions/story_steps.rb on lines 29..32
            dummy/features/step_definitions/task_steps.rb on lines 25..28
            dummy/features/step_definitions/vacancy_steps.rb on lines 28..31

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

            Then /^I should see the following tasks:$/ 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: Major
            Found in dummy/features/step_definitions/task_steps.rb and 6 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 30..33
            dummy/features/step_definitions/product_steps.rb on lines 11..14
            dummy/features/step_definitions/project_steps.rb on lines 19..22
            dummy/features/step_definitions/story_steps.rb on lines 29..32
            dummy/features/step_definitions/vacancy_steps.rb on lines 28..31

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

            Then /^I should see the following projects:$/ 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: Major
            Found in dummy/features/step_definitions/project_steps.rb and 6 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 30..33
            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/task_steps.rb on lines 25..28
            dummy/features/step_definitions/vacancy_steps.rb on lines 28..31

            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