AyuntamientoMadrid/participacion

View on GitHub
spec/system/comments/budget_investments_spec.rb

Summary

Maintainability
F
4 days
Test Coverage

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

require "rails_helper"

describe "Commenting Budget::Investments" do
  let(:user) { create :user }
  let(:investment) { create :budget_investment }
Severity: Minor
Found in spec/system/comments/budget_investments_spec.rb - About 6 hrs to fix

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

      describe "Moderators" do
        scenario "can create comment as a moderator" do
          moderator = create(:moderator)
    
          login_as(moderator.user)
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 5 hrs to fix
    spec/system/comments/legislation_questions_spec.rb on lines 352..404

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

    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

      scenario "Collapsable comments" do
        parent_comment = create(:comment, body: "Main comment", commentable: investment)
        child_comment  = create(:comment, body: "First subcomment", commentable: investment, parent: parent_comment)
        grandchild_comment = create(:comment, body: "Last subcomment", commentable: investment, parent: child_comment)
    
    
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 4 hrs to fix
    spec/system/comments/legislation_questions_spec.rb on lines 63..97

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

    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

      scenario "Comment order" do
        c1 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 100,
                                                      cached_votes_total: 120, created_at: Time.current - 2)
        c2 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 10,
                                                      cached_votes_total: 12, created_at: Time.current - 1)
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 3 hrs to fix
    spec/system/comments/legislation_questions_spec.rb on lines 100..125

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

    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

      scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do
        old_root = create(:comment, commentable: investment, created_at: Time.current - 10)
        new_root = create(:comment, commentable: investment, created_at: Time.current)
        old_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current - 10)
        new_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current)
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 3 hrs to fix
    spec/system/comments/legislation_questions_spec.rb on lines 128..147

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

    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

      scenario "Paginated comments" do
        per_page = 10
        (per_page + 2).times { create(:comment, commentable: investment) }
    
        visit budget_investment_path(investment.budget, investment)
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 1 hr to fix
    spec/system/comments/legislation_questions_spec.rb on lines 176..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 69.

    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

      scenario "Link to comment show" do
        comment = create(:comment, commentable: investment, user: user)
    
        visit budget_investment_path(investment.budget, investment)
    
    
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 1 hr to fix
    spec/system/comments/legislation_questions_spec.rb on lines 48..60

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

    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

      scenario "Turns links into html links" do
        create :comment, commentable: investment, body: "Built with http://rubyonrails.org/"
    
        visit budget_investment_path(investment.budget, investment)
    
    
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 1 hr to fix
    spec/system/comments/legislation_questions_spec.rb on lines 150..159

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

    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

        scenario "Update" do
          visit budget_investment_path(budget, investment)
    
          within("#comment_#{comment.id}_votes") do
            click_button "I agree"
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 1 hr to fix
    spec/system/comments/budget_investments_spec.rb on lines 566..586

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

    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

        scenario "Trying to vote multiple times" do
          visit budget_investment_path(budget, investment)
    
          within("#comment_#{comment.id}_votes") do
            click_button "I agree"
    Severity: Major
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 1 hr to fix
    spec/system/comments/budget_investments_spec.rb on lines 542..562

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

    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

      scenario "Sanitizes comment body for security" do
        create :comment, commentable: investment,
                         body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
    
        visit budget_investment_path(investment.budget, investment)
    Severity: Minor
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 45 mins to fix
    spec/system/comments/legislation_questions_spec.rb on lines 163..172

    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

      describe "Not logged user" do
        scenario "can not see comments forms" do
          create(:comment, commentable: investment)
          visit budget_investment_path(investment.budget, investment)
    
    
    Severity: Minor
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 35 mins to fix
    spec/system/comments/legislation_questions_spec.rb on lines 194..202

    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

      scenario "Errors on reply" do
        comment = create(:comment, commentable: investment, user: user)
    
        login_as(user)
        visit budget_investment_path(investment.budget, investment)
    Severity: Minor
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 35 mins to fix
    spec/system/comments/legislation_questions_spec.rb on lines 303..313

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

    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

      scenario "N replies" do
        parent = create(:comment, commentable: investment)
    
        7.times do
          create(:comment, commentable: investment, parent: parent)
    Severity: Minor
    Found in spec/system/comments/budget_investments_spec.rb and 1 other location - About 35 mins to fix
    spec/system/comments/legislation_questions_spec.rb on lines 317..326

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

    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/110] (https://rubystyle.guide#80-character-limits)
    Open

        old_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current - 10)

    Line is too long. [133/110] (https://rubystyle.guide#80-character-limits)
    Open

                         body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"

    Line is too long. [112/110] (https://rubystyle.guide#80-character-limits)
    Open

      scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do

    Line is too long. [114/110] (https://rubystyle.guide#80-character-limits)
    Open

        grandchild_comment = create(:comment, body: "Last subcomment", commentable: investment, parent: child_comment)

    Line is too long. [112/110] (https://rubystyle.guide#80-character-limits)
    Open

        child_comment  = create(:comment, body: "First subcomment", commentable: investment, parent: parent_comment)

    Line is too long. [123/110] (https://rubystyle.guide#80-character-limits)
    Open

        expect(page).to have_link "Go back to #{investment.title}", href: budget_investment_path(investment.budget, investment)

    There are no issues that match your filters.

    Category
    Status