discourse/discourse

View on GitHub
plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb

Summary

Maintainability
D
2 days
Test Coverage

File advanced_user_narrative_spec.rb has 516 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
  let(:discobot_user) { User.find(-2) }
  let(:first_post) { Fabricate(:post, user: discobot_user) }

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

          describe 'when user replies to the topic' do
            it 'should create the right reply' do
              narrative.input(:reply, user, post: post)
              new_post = Post.last
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 500..525
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 592..614
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 856..878

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

    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 'when user replies to the topic' do
            it 'should create the right reply' do
              narrative.input(:reply, user, post: post)
              new_post = Post.last
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 426..451
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 592..614
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 856..878

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

    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 'when user replies to the topic' do
            it 'should create the right reply' do
              narrative.input(:reply, user, post: post)
              new_post = Post.last
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 426..451
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 500..525
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 856..878

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

    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 'when reply contains the skip trigger' do
              it 'should create the right reply' do
                post.update!(raw: "@#{discobot_user.username} #{skip_trigger.upcase}")
                described_class.any_instance.expects(:enqueue_timeout_job).with(user)
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 232..243

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

            it 'should create the right reply' do
              TopicUser.change(
                user.id,
                topic.id,
                notification_level: TopicUser.notification_levels[:tracking]
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 554..568

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

    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 'should create the right reply' do
              TopicUser.change(
                user.id,
                topic.id,
                notification_level: TopicUser.notification_levels[:tracking]
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 531..545

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

    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 'should create the right reply' do
              narrative.expects(:enqueue_timeout_job).with(user).once
    
              narrative.input(:reply, user, post: post)
              new_post = Post.last
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 206..213

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

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

          describe 'when post is not in the right topic' do
            it 'should not do anything' do
              other_post
              narrative.expects(:enqueue_timeout_job).with(user).never
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 413..422
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 582..588
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 643..649
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 272..278
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 375..381
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 535..541
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 599..605
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 676..682
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 760..766
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 908..914

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

          describe 'when post is not in the right topic' do
            it 'should not do anything' do
              other_post
              narrative.expects(:enqueue_timeout_job).with(user).never
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 142..148
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 413..422
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 643..649
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 272..278
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 375..381
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 535..541
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 599..605
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 676..682
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 760..766
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 908..914

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

          describe 'when post is not in the right topic' do
            it 'should not do anything' do
              other_post
              narrative.expects(:enqueue_timeout_job).with(user).never
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 142..148
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 582..588
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 643..649
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 272..278
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 375..381
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 535..541
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 599..605
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 676..682
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 760..766
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 908..914

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

          describe 'when post is not in the right topic' do
            it 'should not do anything' do
              other_post
              narrative.expects(:enqueue_timeout_job).with(user).never
    
    
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 142..148
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 413..422
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb on lines 582..588
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 272..278
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 375..381
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 535..541
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 599..605
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 676..682
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 760..766
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 908..914

    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

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

          expect(Post.last.raw).to eq(I18n.t(
            'discourse_narrative_bot.timeout.message',
            username: user.username,
            skip_trigger: skip_trigger,
            reset_trigger: "#{reset_trigger} #{described_class.reset_trigger}",
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 47..53

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

    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

          let(:topic) do
            topic_allowed_user = Fabricate.build(:topic_allowed_user, user: user)
            bot = Fabricate.build(:topic_allowed_user, user: discobot_user)
            Fabricate(:private_message_topic, topic_allowed_users: [topic_allowed_user, bot])
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb on lines 65..68
    plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb on lines 686..689

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

    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