spec/features/admin/budget_investments_spec.rb

Summary

Maintainability
F
3 days
Test Coverage

File budget_investments_spec.rb has 1070 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

feature 'Admin budget investments' do

  let(:budget) { create(:budget) }
Severity: Major
Found in spec/features/admin/budget_investments_spec.rb - About 2 days to fix

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

        scenario "Showing the valuating checkbox" do
          investment1 = create(:budget_investment, budget: budget, visible_to_valuators: true)
          investment2 = create(:budget_investment, budget: budget, visible_to_valuators: false)
    
          investment1.valuators << create(:valuator)
    Severity: Major
    Found in spec/features/admin/budget_investments_spec.rb and 1 other location - About 2 hrs to fix
    spec/features/admin/budget_investments_spec.rb on lines 1420..1443

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

    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

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

        scenario "Showing the valuating checkbox" do
          investment1 = create(:budget_investment, budget: budget, visible_to_valuators: true)
          investment2 = create(:budget_investment, budget: budget, visible_to_valuators: false)
    
          investment1.valuators << create(:valuator)
    Severity: Major
    Found in spec/features/admin/budget_investments_spec.rb and 1 other location - About 2 hrs to fix
    spec/features/admin/budget_investments_spec.rb on lines 1255..1278

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

    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

          within("#budget_investment_#{budget_investment2.id}") do
            expect(page).to have_content("No admin assigned")
            expect(page).to have_content("Valuator Olga")
            expect(page).to have_content("Valuator Miriam")
            expect(page).to have_content("No valuation groups assigned")
    Severity: Minor
    Found in spec/features/admin/budget_investments_spec.rb and 1 other location - About 20 mins to fix
    spec/features/admin/budgets_spec.rb on lines 327..331

    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

    Line is too long. [102/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, budget: budget, title: 'More schools',         tag_list: 'Education')

    Provide the actual you are testing to expect(...). (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual)
    Open

          expect('A Second Investment').to appear_before('C Third Investment')

    Use let instead of an instance variable. (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceVariable)
    Open

        login_as(@admin.user)

    Line is too long. [114/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        let!(:unfeasible_bi)  { create(:budget_investment, :unfeasible, budget: budget, title: "Unfeasible project") }

    Line is too long. [102/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, budget: budget, title: 'Educate the children', tag_list: 'Education')

    Line is too long. [101/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, heading: parks, cached_votes_up: 99, title: "Park with 99 supports")

    Line is too long. [104/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuated = create(:budget_investment, budget: budget, title: "Old idea", valuation_finished: true)

    Line is too long. [127/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuating = create(:budget_investment, budget: budget, title: "Ongoing valuation", administrator: create(:administrator))

    Line is too long. [127/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

                         "Budget Heading,Feasible (€99),Yes,Yes,Yes,#{first_investment.author.username}\n#{second_investment.id},"\

    Provide the actual you are testing to expect(...). (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual)
    Open

          expect('B First Investment').to appear_before('A Second Investment')

    Line is too long. [111/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, title: "Plant trees", budget: budget, group: group2, heading: group2_heading1)

    Line is too long. [111/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          administrator = create(:administrator, user: create(:user, username: 'Marta', email: 'marta@admins.org'))

    Line is too long. [106/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuator3 = create(:valuator, user: create(:user, username: 'Val',       email: 'v3@valuators.org'))

    Provide the actual you are testing to expect(...). (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual)
    Open

          expect('C Third Investment').to appear_before('A Second Investment')

    Line is too long. [125/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        let!(:feasible_vf_bi) { create(:budget_investment, :feasible, :finished, budget: budget, title: "Feasible, VF project") }

    Line is too long. [170/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          expect(page).to have_content 'The budget has to stay on phase "Balloting projects", "Reviewing Ballots" or "Finished budget" in order to calculate winners projects'

    Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, heading: roads, cached_votes_up: 100, title: "Road with 100 supports")

    Line is too long. [106/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuator2 = create(:valuator, user: create(:user, username: 'Valerian',  email: 'v2@valuators.org'))

    Line is too long. [110/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        let!(:feasible_bi)    { create(:budget_investment, :feasible, budget: budget, title: "Feasible project") }

    Line is too long. [106/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        let!(:winner_bi)      { create(:budget_investment, :winner, budget: budget, title: "Winner project") }

    Provide the actual you are testing to expect(...). (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual)
    Open

          expect('A Second Investment').to appear_before('B First Investment')

    Provide the actual you are testing to expect(...). (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual)
    Open

          expect('A Second Investment').to appear_before('B First Investment')

    Line is too long. [107/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, heading: streets, cached_votes_up: 300, title: "Street with 300 supports")

    Line is too long. [111/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, title: "Change name", budget: budget, group: group1, heading: group1_heading2)

    Line is too long. [122/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          assigned = create(:budget_investment, title: "Assigned idea", budget: budget, administrator: create(:administrator))

    Provide the actual you are testing to expect(...). (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual)
    Open

          expect('B First Investment').to appear_before('C Third Investment')

    Line is too long. [104/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuator1 = create(:valuator, user: create(:user, username: 'Olga'), description: 'Valuator Olga')

    Line is too long. [107/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, title: "Realocate visitors", budget: budget, administrator: administrator)

    Line is too long. [103/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, heading: roads, cached_votes_up: 199, title: "Road with 199 supports")

    Line is too long. [107/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, heading: streets, cached_votes_up: 200, title: "Street with 200 supports")

    Line is too long. [106/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))

    Line is too long. [106/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuator1 = create(:valuator, user: create(:user, username: 'Valentina', email: 'v1@valuators.org'))

    Line is too long. [108/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          valuator2 = create(:valuator, user: create(:user, username: 'Miriam'), description: 'Valuator Miriam')

    Line is too long. [110/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        let!(:selected_bi)    { create(:budget_investment, :selected, budget: budget, title: "Selected project") }

    Line is too long. [101/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, heading: parks, cached_votes_up: 40, title: "Park with 40 supports")

    Line is too long. [112/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

        let!(:undecided_bi)   { create(:budget_investment, :undecided, budget: budget, title: "Undecided project") }

    Line is too long. [118/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
    Open

          create(:budget_investment, title: "Realocate visitors", budget: budget, group: group1, heading: group1_heading1)

    There are no issues that match your filters.

    Category
    Status