spec/models/debate_spec.rb

Summary

Maintainability
F
5 days
Test Coverage

File debate_spec.rb has 590 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

describe Debate do
  let(:debate) { build(:debate) }

Severity: Major
Found in spec/models/debate_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(:debate,  title: 'stop corruption', cached_votes_up: 1)
            highest_score = create(:debate,  title: 'stop corruption', cached_votes_up: 2)
    Severity: Major
    Found in spec/models/debate_spec.rb and 1 other location - About 1 day to fix
    spec/models/proposal_spec.rb on lines 589..668

    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(:debate) { create(:debate) }
    
        it "expires cache when it has a new comment" do
          expect { create(:comment, commentable: debate) }
    Severity: Major
    Found in spec/models/debate_spec.rb and 1 other location - About 4 hrs to fix
    spec/models/proposal_spec.rb on lines 349..395

    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(:debate) { create(:debate) }
    
        before { Setting["max_votes_for_debate_edit"] = 3 }
        after { Setting["max_votes_for_debate_edit"] = 1000 }
    Severity: Major
    Found in spec/models/debate_spec.rb and 1 other location - About 2 hrs to fix
    spec/models/proposal_spec.rb on lines 163..183

    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 debates ordered by cached_votes_total" do
          debate1 =  create(:debate, cached_votes_total: 1, tag_list: "Sport")
          debate2 =  create(:debate, cached_votes_total: 5, tag_list: "Sport")
          debate3 =  create(:debate, cached_votes_total: 10, tag_list: "Sport")
          proposal = create(:proposal, tag_list: "Sport")
    Severity: Major
    Found in spec/models/debate_spec.rb and 1 other location - About 1 hr to fix
    spec/models/proposal_spec.rb on lines 923..934

    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 votes" do
            title_some_votes    = create(:debate, title: 'stop corruption', cached_votes_up: 5)
            title_least_voted   = create(:debate, title: 'stop corruption', cached_votes_up: 2)
            title_most_voted    = create(:debate, title: 'stop corruption', cached_votes_up: 10)
            description_most_voted = create(:debate, description: 'stop corruption', cached_votes_up: 10)
    Severity: Major
    Found in spec/models/debate_spec.rb and 1 other location - About 1 hr to fix
    spec/models/proposal_spec.rb on lines 562..574

    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

        context "accents" do
    
          it "searches with accents" do
            debate = create(:debate, title: 'difusión')
    
    
    Severity: Major
    Found in spec/models/debate_spec.rb and 1 other location - About 1 hr to fix
    spec/models/proposal_spec.rb on lines 504..517

    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

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

    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 debates when user is the author" do
          debate1 =  create(:debate, author: user, tag_list: "Sport")
          debate2 =  create(:debate, tag_list: "Sport")
          proposal = create(:proposal, tag_list: "Sport")
          create(:follow, followable: proposal, user: user)
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 1 hr to fix
    spec/models/proposal_spec.rb on lines 958..967

    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
          debate = create(:debate, tag_list: "foo")
          tag = ActsAsTaggableOn::Tag.where(name: 'foo').first
          expect(tag.debates_count).to eq(1)
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 55 mins to fix
    spec/models/proposal_spec.rb on lines 304..314

    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 debates related with user interests" do
          debate1 =  create(:debate, tag_list: "Sport")
          debate2 =  create(:debate, tag_list: "Politics")
          proposal1 = create(:proposal, tag_list: "Sport")
          create(:follow, followable: proposal1, user: user)
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 55 mins to fix
    spec/models/proposal_spec.rb on lines 937..946

    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

        context "stemming" do
    
          it "searches word stems" do
            debate = create(:debate, title: 'limpiar')
    
    
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 50 mins to fix
    spec/models/proposal_spec.rb on lines 487..499

    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 "case" do
          it "searches case insensite" do
            debate = create(:debate, title: 'SHOUT')
    
            results = described_class.search('shout')
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 45 mins to fix
    spec/models/proposal_spec.rb on lines 521..530

    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 "#title" do
        it "is not valid without a title" do
          debate.title = nil
          expect(debate).not_to be_valid
        end
    Severity: Major
    Found in spec/models/debate_spec.rb and 3 other locations - About 45 mins to fix
    spec/models/budget/investment_spec.rb on lines 19..32
    spec/models/proposal_spec.rb on lines 27..40
    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

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

    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

        it "increases for debates with more confidence" do
          more_confidence = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 1000, cached_votes_up: 700)
          less_confidence = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 10, cached_votes_up: 9)
          expect(more_confidence.hot_score).to be > less_confidence.hot_score
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 35 mins to fix
    spec/models/debate_spec.rb on lines 251..254

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

    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 debates with more positive votes" do
          more_likes = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 10, cached_votes_up: 5)
          less_likes = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 10, cached_votes_up: 1)
          expect(more_likes.hot_score).to be > less_likes.hot_score
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 35 mins to fix
    spec/models/debate_spec.rb on lines 257..260

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

    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
            debate = create(:debate, tag_list: 'Latina')
    
            results = described_class.search('Latina')
    Severity: Minor
    Found in spec/models/debate_spec.rb and 2 other locations - About 30 mins to fix
    spec/models/budget/investment_spec.rb on lines 635..643
    spec/models/proposal_spec.rb on lines 534..542

    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 debates' do
          debate = create(:debate)
          expect(described_class.public_for_api).to include(debate)
        end
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 25 mins to fix
    spec/models/proposal_spec.rb on lines 865..873

    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 debates with more comments" do
          more_comments = create(:debate, :with_hot_score, created_at: now, comments_count: 25)
          less_comments = create(:debate, :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/debate_spec.rb and 3 other locations - About 25 mins to fix
    spec/models/proposal_spec.rb on lines 263..266
    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 debates" do
          old = create(:debate, :with_hot_score, created_at: now - 1.day)
          new = create(:debate, :with_hot_score, created_at: now)
          expect(new.hot_score).to be > old.hot_score
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 25 mins to fix
    spec/models/proposal_spec.rb on lines 257..260

    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 "increases with comments" do
            previous = debate.hot_score
            25.times{ Comment.create(user: create(:user), commentable: debate, body: 'foobarbaz') }
            expect(previous).to be < debate.reload.hot_score
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 20 mins to fix
    spec/models/proposal_spec.rb on lines 296..299

    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 "registers vote" do
            user = create(:user, residence_verified_at: Time.current, confirmed_phone: "666333111")
            expect {debate.register_vote(user, 'yes')}.to change{debate.reload.votes_for.size}.by(1)
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 20 mins to fix
    spec/models/proposal_spec.rb on lines 210..212

    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 "decreases with dislikes" do
            debate.register_vote(create(:user), true)
            previous = debate.confidence_score
            3.times { debate.register_vote(create(:user), false) }
            expect(previous).to be > debate.confidence_score
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 20 mins to fix
    spec/models/debate_spec.rb on lines 278..282

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

          it "decreases with dislikes" do
            debate.register_vote(create(:user), true)
            previous = debate.hot_score
            3.times { debate.register_vote(create(:user), false) }
            expect(previous).to be > debate.hot_score
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 20 mins to fix
    spec/models/debate_spec.rb on lines 324..328

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

          it "searches by geozone" do
            geozone = create(:geozone, name: 'California')
            debate = create(:debate, geozone: geozone)
            results = described_class.search('California')
            expect(results).to eq([debate])
    Severity: Minor
    Found in spec/models/debate_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/proposal_spec.rb on lines 471..475
    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 5 locations. Consider refactoring.
    Open

          it "searches by author name" do
            author = create(:user, username: 'Danny Trejo')
            debate = create(:debate, author: author)
            results = described_class.search('Danny')
            expect(results).to eq([debate])
    Severity: Minor
    Found in spec/models/debate_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 467..471
    spec/models/proposal_spec.rb on lines 471..475
    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 {debate.register_vote(user, 'yes')}.to change{debate.reload.votes_for.size}.by(1)
    Severity: Minor
    Found in spec/models/debate_spec.rb and 1 other location - About 15 mins to fix
    spec/models/proposal_spec.rb on lines 217..219

    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

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

          more_likes = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 10, cached_votes_up: 5)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

          debate = create(:debate, :with_confidence_score, cached_votes_up: 750, cached_votes_total: 1000)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

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

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

          debate = create(:debate, :with_confidence_score, cached_votes_up: 100, cached_votes_score: 100, cached_votes_total: 100)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

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

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

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

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

            description_most_voted = create(:debate, description: 'stop corruption', cached_votes_up: 10)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

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

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

          less_confidence = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 10, cached_votes_up: 9)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

            expect {debate.register_vote(user, 'yes')}.to change {debate.reload.cached_anonymous_votes_total}.by(1)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

          more_confidence = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 1000, cached_votes_up: 700)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

            expect {debate.register_vote(user, 'yes')}.not_to change{debate.reload.cached_anonymous_votes_total}
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

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

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

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

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

          less_likes = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 10, cached_votes_up: 1)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

          new_less_voted   = create(:debate, :with_hot_score, created_at: now, cached_votes_total: 10, cached_votes_up: 9)
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

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

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

            expect {debate.register_vote(user, 'yes')}.not_to change{debate.reload.cached_anonymous_votes_total}
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

            expect {debate.register_vote(user, 'yes')}.not_to change {debate.reload.cached_anonymous_votes_total}
    Severity: Minor
    Found in spec/models/debate_spec.rb by rubocop

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

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

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

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

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

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

    There are no issues that match your filters.

    Category
    Status