mysociety/alaveteli

View on GitHub
spec/lib/user_spam_scorer_spec.rb

Summary

Maintainability
D
1 day
Test Coverage

File user_spam_scorer_spec.rb has 410 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

describe UserSpamScorer do

  after(:each) { described_class.reset }
Severity: Minor
Found in spec/lib/user_spam_scorer_spec.rb - About 5 hrs to fix

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

      describe '#email_from_suspicious_domain?' do
    
        it 'is true if the email is from a suspicious domain' do
          mock_suspicious_domains = %w(example.com example.net example.org)
          user = mock_model(User, :email_domain => 'example.net')
    Severity: Major
    Found in spec/lib/user_spam_scorer_spec.rb and 2 other locations - About 1 hr to fix
    spec/lib/user_spam_scorer_spec.rb on lines 361..374
    spec/lib/user_spam_scorer_spec.rb on lines 379..392

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

    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

      describe '#email_from_spam_domain?' do
    
        it 'is true if the email is from a spam domain' do
          mock_spam_domains = %w(example.com example.net example.org)
          user = mock_model(User, :email_domain => 'example.net')
    Severity: Major
    Found in spec/lib/user_spam_scorer_spec.rb and 2 other locations - About 1 hr to fix
    spec/lib/user_spam_scorer_spec.rb on lines 341..356
    spec/lib/user_spam_scorer_spec.rb on lines 379..392

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

    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

      describe '#email_from_spam_tld?' do
    
        it 'is true if the email is from a spam tld' do
          mock_spam_tlds = %w(com net org)
          user = mock_model(User, :email_domain => 'example.net')
    Severity: Major
    Found in spec/lib/user_spam_scorer_spec.rb and 2 other locations - About 1 hr to fix
    spec/lib/user_spam_scorer_spec.rb on lines 341..356
    spec/lib/user_spam_scorer_spec.rb on lines 361..374

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

    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 '#name_is_all_lowercase?' do
    
        it 'is true if the name is all lowercase' do
          user = mock_model(User, :name => 'bob smith 123')
          expect(subject.name_is_all_lowercase?(user)).to eq(true)
    Severity: Major
    Found in spec/lib/user_spam_scorer_spec.rb and 3 other locations - About 40 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 289..298
    spec/lib/user_spam_scorer_spec.rb on lines 303..312
    spec/lib/user_spam_scorer_spec.rb on lines 513..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 38.

    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 '#name_is_one_word?' do
    
        it 'is true if the name is one word' do
          user = mock_model(User, :name => 'bobsmith123')
          expect(subject.name_is_one_word?(user)).to eq(true)
    Severity: Major
    Found in spec/lib/user_spam_scorer_spec.rb and 3 other locations - About 40 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 275..284
    spec/lib/user_spam_scorer_spec.rb on lines 303..312
    spec/lib/user_spam_scorer_spec.rb on lines 513..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 38.

    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 '#name_is_garbled?' do
    
        it 'is true if the name includes 5 consecutive consonants' do
          user = mock_model(User, :name => 'JWahewKjWhebCd')
          expect(subject.name_is_garbled?(user)).to eq(true)
    Severity: Major
    Found in spec/lib/user_spam_scorer_spec.rb and 3 other locations - About 40 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 275..284
    spec/lib/user_spam_scorer_spec.rb on lines 289..298
    spec/lib/user_spam_scorer_spec.rb on lines 513..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 38.

    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 '#about_me_includes_anchor_tag?' do
    
        it 'is true if the about me includes an a tag' do
          user = mock_model(User, :about_me => 'Spam link <a href="">here</a>')
          expect(subject.about_me_includes_anchor_tag?(user)).to eq(true)
    Severity: Major
    Found in spec/lib/user_spam_scorer_spec.rb and 3 other locations - About 40 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 275..284
    spec/lib/user_spam_scorer_spec.rb on lines 289..298
    spec/lib/user_spam_scorer_spec.rb on lines 303..312

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

    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 false if the user spam score is equal to the threshold' do
          user_attrs = { :name => 'genuine', :comments => [], :track_things => [] }
          user = mock_model(User, user_attrs)
          attrs = { :score_mappings => { :name_is_one_word? => 5 },
                    :spam_score_threshold => 5 }
    Severity: Minor
    Found in spec/lib/user_spam_scorer_spec.rb and 1 other location - About 35 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 213..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 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

        it 'returns false if the user spam score is below the threshold' do
          user_attrs = { :name => 'genuine', :comments => [], :track_things => [] }
          user = mock_model(User, user_attrs)
          attrs = { :score_mappings => { :name_is_one_word? => 5 },
                    :spam_score_threshold => 100 }
    Severity: Minor
    Found in spec/lib/user_spam_scorer_spec.rb and 1 other location - About 35 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 204..210

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

      describe '.suspicious_domains' do
    
        it 'sets a default suspicious_domains value' do
          expect(described_class.suspicious_domains).
            to eq(described_class::DEFAULT_SUSPICIOUS_DOMAINS)
    Severity: Minor
    Found in spec/lib/user_spam_scorer_spec.rb and 2 other locations - About 25 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 50..59
    spec/lib/user_spam_scorer_spec.rb on lines 92..101

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

      describe '.spam_domains' do
    
        it 'sets a default spam_domains value' do
          expect(described_class.spam_domains).
            to eq(described_class::DEFAULT_SPAM_DOMAINS )
    Severity: Minor
    Found in spec/lib/user_spam_scorer_spec.rb and 2 other locations - About 25 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 36..45
    spec/lib/user_spam_scorer_spec.rb on lines 92..101

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

      describe '.spam_tlds' do
    
        it 'sets a default spam_tlds value' do
          expect(described_class.spam_tlds).
            to eq(described_class::DEFAULT_SPAM_TLDS)
    Severity: Minor
    Found in spec/lib/user_spam_scorer_spec.rb and 2 other locations - About 25 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 36..45
    spec/lib/user_spam_scorer_spec.rb on lines 50..59

    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 'is true if the about me matches a spammy format' do
          mock_spam_formats = [/\A.*+\n{2,}https?:\/\/[^\s]+\z/]
          user = mock_model(User, :about_me => <<-EOF.strip_heredoc)
          Some spam often looks like this spam
    
    
    Severity: Minor
    Found in spec/lib/user_spam_scorer_spec.rb and 1 other location - About 20 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 469..475

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 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 'replaces \r\n with \n' do
          mock_spam_formats = [/\Aspam\nspam\z/]
          user = mock_model(User, :about_me => <<-EOF.strip_heredoc)
          spam\r\nspam
          EOF
    Severity: Minor
    Found in spec/lib/user_spam_scorer_spec.rb and 1 other location - About 20 mins to fix
    spec/lib/user_spam_scorer_spec.rb on lines 451..459

    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

    There are no issues that match your filters.

    Category
    Status