spec/models/proposal_spec.rb

Summary

Maintainability
F
6 days
Test Coverage

File proposal_spec.rb has 757 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

describe Proposal do
  let(:proposal) { build(:proposal) }

Severity: Major
Found in spec/models/proposal_spec.rb - About 1 day to fix

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

        context "reorder" do
    
          it "is able to reorder by hot_score after searching" do
            lowest_score  = create(:proposal,  title: 'stop corruption', cached_votes_up: 1)
            highest_score = create(:proposal,  title: 'stop corruption', cached_votes_up: 2)
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 1 day to fix
    spec/models/debate_spec.rb on lines 575..654

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

    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

      describe "cache" do
        let(:proposal) { create(:proposal) }
    
        it "expires cache when it has a new comment" do
          expect { create(:comment, commentable: proposal) }
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 4 hrs to fix
    spec/models/debate_spec.rb on lines 334..380

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

    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

      describe "#editable?" do
        let(:proposal) { create(:proposal) }
    
        before {Setting["max_votes_for_proposal_edit"] = 5}
        after {Setting["max_votes_for_proposal_edit"] = 1000}
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 2 hrs to fix
    spec/models/debate_spec.rb on lines 89..109

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

    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

        it "returns proposals ordered by cached_votes_up" do
          proposal1 = create(:proposal, cached_votes_up: 1,  tag_list: "Sport")
          proposal2 = create(:proposal, cached_votes_up: 5,  tag_list: "Sport")
          proposal3 = create(:proposal, cached_votes_up: 10, tag_list: "Sport")
          proposal4 = create(:proposal, tag_list: "Sport")
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 1 hr to fix
    spec/models/debate_spec.rb on lines 732..743

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

    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

          it "orders by weight and then by votes" do
            title_some_votes    = create(:proposal, title: 'stop corruption', cached_votes_up: 5)
            title_least_voted   = create(:proposal, title: 'stop corruption', cached_votes_up: 2)
            title_most_voted    = create(:proposal, title: 'stop corruption', cached_votes_up: 10)
    
    
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 1 hr to fix
    spec/models/debate_spec.rb on lines 549..560

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

    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

      describe "tag_list" do
        it "sanitizes the tag list" do
          proposal.tag_list = "user_id=1"
          proposal.valid?
          expect(proposal.tag_list).to eq(['user_id1'])
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 1 hr to fix
    spec/models/debate_spec.rb on lines 66..80

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

    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

        context "accents" do
          it "searches with accents" do
            proposal = create(:proposal, summary: 'difusión')
    
            results = described_class.search('difusion')
    Severity: Major
    Found in spec/models/proposal_spec.rb and 1 other location - About 1 hr to fix
    spec/models/debate_spec.rb on lines 493..507

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

    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

        it "does not return proposals when user is the author" do
          proposal1 =  create(:proposal, author: user, tag_list: "Sport")
          proposal2 =  create(:proposal, tag_list: "Sport")
          proposal3 =  create(:proposal, tag_list: "Sport")
          create(:follow, followable: proposal3, user: user)
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 1 hr to fix
    spec/models/debate_spec.rb on lines 758..767

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

    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

      describe "custom tag counters when hiding/restoring" do
        it "decreases the tag counter when hiden, and increases it when restored" do
          proposal = create(:proposal, tag_list: "foo")
          tag = ActsAsTaggableOn::Tag.where(name: 'foo').first
          expect(tag.proposals_count).to eq(1)
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 55 mins to fix
    spec/models/debate_spec.rb on lines 384..394

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

    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

        it "returns proposals related with user interests" do
          proposal1 =  create(:proposal, tag_list: "Sport")
          proposal2 =  create(:proposal, tag_list: "Sport")
          proposal3 =  create(:proposal, tag_list: "Politics")
          create(:follow, followable: proposal1, user: user)
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 55 mins to fix
    spec/models/debate_spec.rb on lines 746..755

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

    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

        it "does not return users that have been blocked" do
          proposal = create(:proposal)
          voter1 = create(:user, :level_two)
          voter2 = create(:user, :level_two)
    
    
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 50 mins to fix
    spec/models/proposal_spec.rb on lines 415..425

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

    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

        context "stemming" do
    
          it "searches word stems" do
            proposal = create(:proposal, summary: 'Economía')
    
    
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 50 mins to fix
    spec/models/debate_spec.rb on lines 476..488

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

    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

        it "does not return users that have been erased" do
          proposal = create(:proposal)
          voter1 = create(:user, :level_two)
          voter2 = create(:user, :level_two)
    
    
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 50 mins to fix
    spec/models/proposal_spec.rb on lines 428..438

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

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

      describe "#title" do
        it "is not valid without a title" do
          proposal.title = nil
          expect(proposal).not_to be_valid
        end
    Severity: Major
    Found in spec/models/proposal_spec.rb and 3 other locations - About 45 mins to fix
    spec/models/budget/investment_spec.rb on lines 19..32
    spec/models/debate_spec.rb on lines 21..34
    spec/models/proposal_spec.rb on lines 57..70

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

    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

        context "case" do
          it "searches case insensite" do
            proposal = create(:proposal, title: 'SHOUT')
    
            results = described_class.search('shout')
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 45 mins to fix
    spec/models/debate_spec.rb on lines 512..521

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

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

      describe "#question" do
        it "is not valid without a question" do
          proposal.question = nil
          expect(proposal).not_to be_valid
        end
    Severity: Major
    Found in spec/models/proposal_spec.rb and 3 other locations - About 45 mins to fix
    spec/models/budget/investment_spec.rb on lines 19..32
    spec/models/debate_spec.rb on lines 21..34
    spec/models/proposal_spec.rb on lines 27..40

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

    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

          it "gives much more weight to word matches than votes" do
            exact_title_few_votes    = create(:proposal, title: 'stop corruption', cached_votes_up: 5)
            similar_title_many_votes = create(:proposal, title: 'stop some of the corruption', cached_votes_up: 500)
    
            results = described_class.search('stop corruption')
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 35 mins to fix
    spec/models/debate_spec.rb on lines 563..570

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

        context "tags" do
          it "searches by tags" do
            proposal = create(:proposal, tag_list: 'Latina')
    
            results = described_class.search('Latina')
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 2 other locations - About 30 mins to fix
    spec/models/budget/investment_spec.rb on lines 635..643
    spec/models/debate_spec.rb on lines 525..533

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

    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

      describe 'public_for_api scope' do
        it 'returns proposals' do
          proposal = create(:proposal)
          expect(described_class.public_for_api).to include(proposal)
        end
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 25 mins to fix
    spec/models/debate_spec.rb on lines 710..718

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

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

        it "increases for proposals with more confidence" do
          more_confidence = create(:proposal, :with_hot_score, created_at: now, cached_votes_up: 700)
          less_confidence = create(:proposal, :with_hot_score, created_at: now, cached_votes_up: 9)
          expect(more_confidence.hot_score).to be > less_confidence.hot_score
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 3 other locations - About 25 mins to fix
    spec/models/debate_spec.rb on lines 245..248
    spec/models/proposal_spec.rb on lines 263..266
    spec/models/proposal_spec.rb on lines 269..272

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

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

        it "increases for proposals with more positive votes" do
          more_likes = create(:proposal, :with_hot_score, created_at: now, cached_votes_up: 5)
          less_likes = create(:proposal, :with_hot_score, created_at: now, cached_votes_up: 1)
          expect(more_likes.hot_score).to be > less_likes.hot_score
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 3 other locations - About 25 mins to fix
    spec/models/debate_spec.rb on lines 245..248
    spec/models/proposal_spec.rb on lines 263..266
    spec/models/proposal_spec.rb on lines 275..278

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

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

        it "increases for proposals with more comments" do
          more_comments = create(:proposal, :with_hot_score, created_at: now, comments_count: 25)
          less_comments = create(:proposal, :with_hot_score, created_at: now, comments_count: 1)
          expect(more_comments.hot_score).to be > less_comments.hot_score
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 3 other locations - About 25 mins to fix
    spec/models/debate_spec.rb on lines 245..248
    spec/models/proposal_spec.rb on lines 269..272
    spec/models/proposal_spec.rb on lines 275..278

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

    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

        it "increases for newer proposals" do
          old = create(:proposal, :with_hot_score, created_at: now - 1.day)
          new = create(:proposal, :with_hot_score, created_at: now)
          expect(new.hot_score).to be > old.hot_score
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 25 mins to fix
    spec/models/debate_spec.rb on lines 239..242

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

    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

          it "registers vote" do
            user = create(:user, residence_verified_at: Time.current, confirmed_phone: "666333111")
            expect {proposal.register_vote(user, 'yes')}.to change{proposal.reload.votes_for.size}.by(1)
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 20 mins to fix
    spec/models/debate_spec.rb on lines 177..179

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

    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

          it "increases with comments" do
            previous = proposal.hot_score
            25.times{ Comment.create(user: create(:user), commentable: proposal, body: 'foobarbaz') }
            expect(previous).to be < proposal.reload.hot_score
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 20 mins to fix
    spec/models/debate_spec.rb on lines 285..288

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

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

          it "searches by geozone" do
            geozone = create(:geozone, name: 'California')
            proposal = create(:proposal, geozone: geozone)
            results = described_class.search('California')
            expect(results).to eq([proposal])
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 4 other locations - About 15 mins to fix
    spec/models/budget/investment_spec.rb on lines 626..630
    spec/models/debate_spec.rb on lines 460..464
    spec/models/debate_spec.rb on lines 467..471
    spec/models/proposal_spec.rb on lines 471..475

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

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

          it "searches by author name" do
            author = create(:user, username: 'Danny Trejo')
            proposal = create(:proposal, author: author)
            results = described_class.search('Danny')
            expect(results).to eq([proposal])
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 4 other locations - About 15 mins to fix
    spec/models/budget/investment_spec.rb on lines 626..630
    spec/models/debate_spec.rb on lines 460..464
    spec/models/debate_spec.rb on lines 467..471
    spec/models/proposal_spec.rb on lines 478..482

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

    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

          it "registers vote" do
            user = create(:user, verified_at: Time.current)
            expect {proposal.register_vote(user, 'yes')}.to change{proposal.reload.votes_for.size}.by(1)
    Severity: Minor
    Found in spec/models/proposal_spec.rb and 1 other location - About 15 mins to fix
    spec/models/debate_spec.rb on lines 189..191

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

    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

    Inconsistent indentation detected. (https://github.com/bbatsov/ruby-style-guide#spaces-indentation)
    Open

         it "is the document_number if level three user" do
          author = create(:user, :level_three, document_number: "12345678Z")
          proposal.author = author
          proposal.responsible_name = nil
    
    
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

    This cops checks for inconsistent indentation.

    Example:

    class A
      def test
        puts 'hello'
         puts 'world'
      end
    end

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

            proposal = create(:proposal, description: 'in order to save the world one must think about...')
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

          proposal.tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

          expect {archived_proposal.register_vote(user, 'yes')}.to change{proposal.reload.votes_for.size}.by(0)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

            some_comments   = create(:proposal,  title: 'stop corruption',  cached_votes_up: 3, comments_count: 10)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

            most_commented  = create(:proposal,  title: 'stop corruption',  cached_votes_up: 2, comments_count: 100)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

          expect(described_class.for_summary).to include('culture' => [proposal1, proposal2], 'health' => [proposal3])
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

          proposal.tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"]
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

            least_commented = create(:proposal,  title: 'stop corruption',  cached_votes_up: 1, comments_count: 1)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

            similar_title_many_votes = create(:proposal, title: 'stop some of the corruption', cached_votes_up: 500)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

          older_more_voted = create(:proposal, :with_hot_score, created_at: now - 5.days, cached_votes_up: 900)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

            newest  = create(:proposal,  title: 'stop corruption', cached_votes_up: 2, created_at: Time.current)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

            recent  = create(:proposal,  title: 'stop corruption', cached_votes_up: 1, created_at: 1.week.ago)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

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

            oldest  = create(:proposal,  title: 'stop corruption', cached_votes_up: 3, created_at: 1.month.ago)
    Severity: Minor
    Found in spec/models/proposal_spec.rb by rubocop

    There are no issues that match your filters.

    Category
    Status