expertiza/expertiza

View on GitHub
spec/controllers/teams_users_controller_spec.rb

Summary

Maintainability
D
2 days
Test Coverage

Block has too many lines. [286/25]
Open

describe TeamsUsersController do
  # Including the stubbed objects from the teams_shared.rb file
  include_context 'object initializations'
  # Objects initialization for team users
  let(:teamUser) { build(:team_user, id: 1, team_id: 1, user_id: 1) }

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [189/25]
Open

  describe '#create' do
    context 'when user is added to assignment or course team' do
      it 'it throws error when user is not defined' do
        allow(User).to receive(:find_by).with(name: 'instructor6').and_return(nil)
        allow(Team).to receive(:find).with('1').and_return(team1)

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

File teams_users_controller_spec.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require './spec/support/teams_shared.rb'

describe TeamsUsersController do
  # Including the stubbed objects from the teams_shared.rb file
  include_context 'object initializations'
Severity: Minor
Found in spec/controllers/teams_users_controller_spec.rb - About 2 hrs to fix

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

        context 'when user is added to assignment team' do
          it 'it throws error when assignmentTeam has maximum number of participants' do
            allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
            allow(Team).to receive(:find).with('1').and_return(team1)
            allow(AssignmentTeam).to receive(:find).with('1').and_return(team1)
    Severity: Major
    Found in spec/controllers/teams_users_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/teams_users_controller_spec.rb on lines 182..198

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

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        context 'when user is added to course team while on a team already' do
          it 'it throws error that they are already on a team' do
            allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
            allow(Team).to receive(:find).with('5').and_return(team5)
            allow(CourseTeam).to receive(:find).with('5').and_return(team5)
    Severity: Major
    Found in spec/controllers/teams_users_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/teams_users_controller_spec.rb on lines 245..261

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

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        context 'when user is added to course team' do
          it 'it throws error when courseTeam has maximum number of participants' do
            allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
            allow(Team).to receive(:find).with('5').and_return(team5)
            allow(CourseTeam).to receive(:find).with('5').and_return(team5)
    Severity: Major
    Found in spec/controllers/teams_users_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/teams_users_controller_spec.rb on lines 124..140

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

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        context 'when user is added to assignment team while on a team already' do
          it 'it throws error that they are already on a team' do
            allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
            allow(Team).to receive(:find).with('1').and_return(team1)
            allow(AssignmentTeam).to receive(:find).with('1').and_return(team1)
    Severity: Major
    Found in spec/controllers/teams_users_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/teams_users_controller_spec.rb on lines 289..305

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

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        context 'when user is added to course team' do
          it 'it throws error when user added to course Team is not defined' do
            allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
            allow(Team).to receive(:find).with('5').and_return(team5)
            allow(CourseTeam).to receive(:find).with('5').and_return(team5)
    Severity: Major
    Found in spec/controllers/teams_users_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/teams_users_controller_spec.rb on lines 105..120

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

        context 'when user is added to assignment team' do
          it 'it throws error when user added is not a participant of the current assignment' do
            allow(User).to receive(:find_by).with(name: student1.name).and_return(student1)
            allow(Team).to receive(:find).with('1').and_return(team1)
            allow(AssignmentTeam).to receive(:find).with('1').and_return(team1)
    Severity: Major
    Found in spec/controllers/teams_users_controller_spec.rb and 1 other location - About 2 hrs to fix
    spec/controllers/teams_users_controller_spec.rb on lines 163..178

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

      let(:assignment) do
        build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',
                           participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)
    Severity: Minor
    Found in spec/controllers/teams_users_controller_spec.rb and 4 other locations - About 15 mins to fix
    spec/controllers/assignment_questionnaire_controller_spec.rb on lines 8..10
    spec/controllers/assignments_controller_spec.rb on lines 2..4
    spec/controllers/assignments_controller_spec.rb on lines 6..8
    spec/support/teams_shared.rb on lines 14..16

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 26.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

            allow_any_instance_of(CourseTeam).to receive(:add_member).with(any_args).and_raise("Member on existing team error")

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

            allow_any_instance_of(Team).to receive(:add_member).with(any_args).and_raise("Member on existing team error")

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    There are no issues that match your filters.

    Category
    Status