mysociety/alaveteli

View on GitHub
spec/controllers/admin_censor_rule_controller_spec.rb

Summary

Maintainability
F
6 days
Test Coverage

File admin_censor_rule_controller_spec.rb has 767 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe AdminCensorRuleController do
  before(:each) { basic_auth_login(@request) }

Severity: Major
Found in spec/controllers/admin_censor_rule_controller_spec.rb - About 1 day to fix

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

        context 'a CensorRule with an associated User' do
    
          let(:censor_rule) { FactoryGirl.create(:user_censor_rule) }
    
          it 'finds the correct censor rule to edit' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 6 hrs to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 696..767
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 850..921

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

    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 'a CensorRule with an associated PublicBody' do
    
          let(:censor_rule) { FactoryGirl.create(:public_body_censor_rule) }
    
          it 'finds the correct censor rule to edit' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 6 hrs to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 696..767
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 774..843

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

    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 'a CensorRule with an associated InfoRequest' do
    
          let(:censor_rule) { FactoryGirl.create(:info_request_censor_rule) }
    
          it 'finds the correct censor rule to edit' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 6 hrs to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 774..843
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 850..921

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

    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 'a CensorRule with an associated User' do
    
          let(:censor_rule) { FactoryGirl.create(:user_censor_rule) }
    
          it 'finds the correct censor rule to destroy' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 2 hrs to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 954..980
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 1015..1041

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

    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 'a CensorRule with an associated InfoRequest' do
    
          let(:censor_rule) { FactoryGirl.create(:info_request_censor_rule) }
    
          it 'finds the correct censor rule to destroy' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 2 hrs to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 985..1010
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 1015..1041

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

    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 'a CensorRule with an associated PublicBody' do
    
          let(:censor_rule) { FactoryGirl.create(:public_body_censor_rule) }
    
          it 'finds the correct censor rule to destroy' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 2 hrs to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 954..980
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 985..1010

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

    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 'user_id param' do
    
          let(:user) { FactoryGirl.create(:user) }
    
          before do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 72..102
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 142..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 74.

    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 'request_id param' do
    
          let(:info_request) { FactoryGirl.create(:info_request) }
    
          before do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 107..136
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 142..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 74.

    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 'body_id param' do
    
          let(:public_body) { FactoryGirl.create(:public_body) }
    
          before do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 72..102
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 107..136

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 74.

    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

        context 'a CensorRule with an associated User' do
    
          let(:censor_rule) { FactoryGirl.create(:user_censor_rule) }
    
          it 'returns a successful response' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 532..548
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 574..590
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 595..611

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

    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

        context 'a CensorRule with an associated PublicBody' do
    
          let(:censor_rule) { FactoryGirl.create(:public_body_censor_rule) }
    
          it 'returns a successful response' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 532..548
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 553..569
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 595..611

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

    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

        context 'a CensorRule with an associated InfoRequest' do
    
          let(:censor_rule) { FactoryGirl.create(:info_request_censor_rule) }
    
          it 'returns a successful response' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 553..569
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 574..590
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 595..611

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

    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

        context 'a global rule' do
    
          let(:censor_rule) { FactoryGirl.create(:global_censor_rule) }
    
          it 'returns a successful response' do
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 3 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 532..548
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 553..569
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 574..590

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

    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 'unsuccessfully saving the censor rule' do
    
            before(:each) do
              allow_any_instance_of(CensorRule).to receive(:save).and_return(false)
            end
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 335..350
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 507..522

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

          context 'unsuccessfully saving the censor rule' do
    
            before(:each) do
              allow_any_instance_of(CensorRule).to receive(:save).and_return(false)
            end
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 335..350
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 415..430

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

          context 'unsuccessfully saving the censor rule' do
    
            before(:each) do
              allow_any_instance_of(CensorRule).to receive(:save).and_return(false)
            end
    Severity: Major
    Found in spec/controllers/admin_censor_rule_controller_spec.rb and 2 other locations - About 1 hr to fix
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 415..430
    spec/controllers/admin_censor_rule_controller_spec.rb on lines 507..522

    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

    There are no issues that match your filters.

    Category
    Status