expertiza/expertiza

View on GitHub
spec/controllers/advertise_for_partner_controller_spec.rb

Summary

Maintainability
C
1 day
Test Coverage

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

describe AdvertiseForPartnerController do
  # Including the stubbed objects from the teams_shared.rb file
  include_context 'object initializations'
  let(:team1user1) { build_stubbed(:team_user, id: 1, team: team1, user: student1) }
  let(:team1user2) { build_stubbed(:team_user, id: 2, team: team1, user: student2) }

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. [47/25]
Open

  describe 'action allowed method' do
    context 'when called directly' do
      # Including the shared method from the teams_shared.rb file
      include_context 'authorization check'
      it 'provides access for student' do

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. [38/25]
Open

    context 'performs access check when called before' do
      it 'checks if create method can be called by the user' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(team1).to receive(:update_attributes).with(any_args).and_return(true)
        allow(AssignmentTeam).to receive_message_chain(:find_by, :assignment).and_return(assignment1)

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. [34/25]
Open

  describe 'remove method' do
    context 'when called by a valid member of the current team in user_session' do
      it 'allows to successfully remove the advertisement' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)

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. [34/25]
Open

  describe 'update method called' do
    context 'to update the comment in advertisement by a valid member of the current team in user_session' do
      it 'updates the advertisement successfully' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)

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.

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

    context 'to update the comment in advertisement by a valid member of the current team in user_session' do
      it 'updates the advertisement successfully' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)
        allow(team1).to receive(:assignment).and_return(assignment1)
Severity: Major
Found in spec/controllers/advertise_for_partner_controller_spec.rb and 2 other locations - About 1 hr to fix
spec/controllers/advertise_for_partner_controller_spec.rb on lines 86..98
spec/controllers/advertise_for_partner_controller_spec.rb on lines 146..161

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

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 'when called by a valid member of the current team in user_session' do
      it 'allows to successfully remove the advertisement' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)
        allow(team1).to receive(:assignment).and_return(assignment1)
Severity: Major
Found in spec/controllers/advertise_for_partner_controller_spec.rb and 2 other locations - About 1 hr to fix
spec/controllers/advertise_for_partner_controller_spec.rb on lines 86..98
spec/controllers/advertise_for_partner_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 76.

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 'by a an existing team with advertisement comment' do
      it 'will create an advertisement for the team in current session' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(AssignmentParticipant).to receive(:exists?).and_return(true)
        allow(team1).to receive(:assignment).and_return(assignment1)
Severity: Major
Found in spec/controllers/advertise_for_partner_controller_spec.rb and 2 other locations - About 1 hr to fix
spec/controllers/advertise_for_partner_controller_spec.rb on lines 105..120
spec/controllers/advertise_for_partner_controller_spec.rb on lines 146..161

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

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 'checks if create method can be called by the user' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(team1).to receive(:update_attributes).with(any_args).and_return(true)
        allow(AssignmentTeam).to receive_message_chain(:find_by, :assignment).and_return(assignment1)
        allow(AssignmentParticipant).to receive(:find_by).with(any_args).and_return(participant)
Severity: Major
Found in spec/controllers/advertise_for_partner_controller_spec.rb and 1 other location - About 1 hr to fix
spec/controllers/advertise_for_partner_controller_spec.rb on lines 35..44

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

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 'check if update method can be called by the user' do
        allow(AssignmentTeam).to receive(:find_by).and_return(team1)
        allow(team1).to receive(:update_attributes).with(any_args).and_return(true)
        allow(AssignmentTeam).to receive_message_chain(:find_by, :assignment).and_return(assignment1)
        allow(AssignmentParticipant).to receive(:find_by).with(any_args).and_return(participant)
Severity: Major
Found in spec/controllers/advertise_for_partner_controller_spec.rb and 1 other location - About 1 hr to fix
spec/controllers/advertise_for_partner_controller_spec.rb on lines 24..33

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

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

Unnecessary spacing detected.
Open

  let(:participant) { build(:participant,  id: 1) }

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

There are no issues that match your filters.

Category
Status