Block has too many lines. [430/25] Open
describe SignUpSheetController do
let(:assignment) { build(:assignment, id: 1, instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true) }
let(:instructor) { build(:instructor, id: 6) }
let(:student) { build(:student, id: 8) }
let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }
- Read upRead up
- Exclude checks
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 sign_up_sheet_controller_spec.rb
has 432 lines of code (exceeds 250 allowed). Consider refactoring. Open
describe SignUpSheetController do
let(:assignment) { build(:assignment, id: 1, instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true) }
let(:instructor) { build(:instructor, id: 6) }
let(:student) { build(:student, id: 8) }
let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }
Block has too many lines. [66/25] Open
describe '#signup_as_instructor_action' do
context 'when user cannot be found' do
it 'shows an flash error message and redirects to assignment#edit page' do
allow(User).to receive(:find_by).with(name: 'no name').and_return(nil)
allow(User).to receive(:find).with(8).and_return(student)
- Read upRead up
- Exclude checks
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. [62/25] Open
describe '#create' do
context 'when topic cannot be found' do
context 'when new topic can be saved successfully' do
it 'sets up a new topic and redirects to assignment#edit page' do
allow(SignUpTopic).to receive(:where).with(topic_name: 'Hello world!', assignment_id: '1').and_return([nil])
- Read upRead up
- Exclude checks
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. [53/25] Open
context 'when user can be found' do
before(:each) do
allow(User).to receive(:find_by).with(name: 'no name').and_return(student)
end
- Read upRead up
- Exclude checks
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. [42/25] Open
describe '#delete_signup_as_instructor' do
before(:each) do
allow(Team).to receive(:find).with('1').and_return(team)
allow(TeamsUser).to receive(:find_by).with(team_id: 1).and_return(double('TeamsUser', user: student))
allow(AssignmentParticipant).to receive(:find_by).with(user_id: 8, parent_id: 1).and_return(participant)
- Read upRead up
- Exclude checks
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. [39/25] Open
context 'when topic cannot be found' do
context 'when new topic can be saved successfully' do
it 'sets up a new topic and redirects to assignment#edit page' do
allow(SignUpTopic).to receive(:where).with(topic_name: 'Hello world!', assignment_id: '1').and_return([nil])
allow_any_instance_of(SignUpSheetController).to receive(:undo_link)
- Read upRead up
- Exclude checks
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. [39/25] Open
describe '#delete_signup' do
before(:each) do
allow(participant).to receive(:team).and_return(team)
end
- Read upRead up
- Exclude checks
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. [36/25] Open
context 'when an assignment_participant can be found' do
before(:each) do
allow(AssignmentParticipant).to receive(:exists?).with(user_id: 8, parent_id: '1').and_return(true)
end
- Read upRead up
- Exclude checks
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. [33/25] Open
describe '#update' do
context 'when topic cannot be found' do
it 'shows an error flash message and redirects to assignment#edit page' do
allow(SignUpTopic).to receive(:find).with('1').and_return(nil)
params = {id: 1, assignment_id: 1}
- Read upRead up
- Exclude checks
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. [32/25] Open
describe '#save_topic_deadlines' do
context 'when topic_due_date cannot be found' do
it 'creates a new topic_due_date record and redirects to assignment#edit page' do
assignment.due_dates = [due_date, due_date2]
allow(SignUpTopic).to receive(:where).with(assignment_id: '1').and_return([topic])
- Read upRead up
- Exclude checks
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. [28/25] Open
describe '#list' do
before(:each) do
allow(SignUpTopic).to receive(:find_slots_filled).with(1).and_return([topic])
allow(SignUpTopic).to receive(:find_slots_waitlisted).with(1).and_return([])
allow(SignUpTopic).to receive(:where).with(assignment_id: 1, private_to: nil).and_return([topic])
- Read upRead up
- Exclude checks
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 2 locations. Consider refactoring. Open
context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is not nil and its due date has already passed' do
it 'shows a flash error message and redirects to assignment#edit page' do
due_date.due_at = DateTime.now.in_time_zone - 1.day
allow(assignment.due_dates).to receive(:find_by).with(deadline_type_id: 6).and_return(due_date)
allow(team).to receive(:submitted_files).and_return([])
- Read upRead up
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 65.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is not nil and its due date has already passed' do
it 'shows a flash error message and redirects to sign_up_sheet#list page' do
due_date.due_at = DateTime.now.in_time_zone - 1.day
allow(assignment.due_dates).to receive(:find_by).with(deadline_type_id: 6).and_return(due_date)
allow(team).to receive(:submitted_files).and_return([])
- Read upRead up
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 65.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is nil' do
it 'shows a flash success message and redirects to assignment#edit page' do
allow(team).to receive(:submitted_files).and_return([])
allow(team).to receive(:hyperlinks).and_return([])
allow(SignedUpTeam).to receive(:find_team_users).with(1, 6).and_return([team])
- Read upRead up
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 65.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
context 'when both submitted files and hyperlinks of current team are empty and drop topic deadline is nil' do
it 'shows a flash success message and redirects to sign_up_sheet#list page' do
allow(team).to receive(:submitted_files).and_return([])
allow(team).to receive(:hyperlinks).and_return([])
allow(SignedUpTeam).to receive(:find_team_users).with(1, 6).and_return([team])
- Read upRead up
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 65.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
context 'when either submitted files or hyperlinks of current team are not empty' do
it 'shows a flash error message and redirects to sign_up_sheet#list page' do
allow(assignment).to receive(:instructor).and_return(instructor)
params = {id: 1}
session = {user: instructor}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
context 'when either submitted files or hyperlinks of current team are not empty' do
it 'shows a flash error message and redirects to assignment#edit page' do
allow(assignment).to receive(:instructor).and_return(instructor)
params = {id: 1}
session = {user: instructor}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Prefer Date or Time over DateTime. Open
due_date.due_at = DateTime.now.in_time_zone - 1.day
- Read upRead up
- Exclude checks
This cop checks for uses of DateTime
that should be replaced by
Date
or Time
.
Example:
# bad - uses `DateTime` for current time
DateTime.now
# good - uses `Time` for current time
Time.now
# bad - uses `DateTime` for modern date
DateTime.iso8601('2016-06-29')
# good - uses `Date` for modern date
Date.iso8601('2016-06-29')
# good - uses `DateTime` with start argument for historical date
DateTime.iso8601('1751-04-23', Date::ENGLAND)
Prefer Date or Time over DateTime. Open
due_date.due_at = DateTime.now.in_time_zone - 1.day
- Read upRead up
- Exclude checks
This cop checks for uses of DateTime
that should be replaced by
Date
or Time
.
Example:
# bad - uses `DateTime` for current time
DateTime.now
# good - uses `Time` for current time
Time.now
# bad - uses `DateTime` for modern date
DateTime.iso8601('2016-06-29')
# good - uses `Date` for modern date
Date.iso8601('2016-06-29')
# good - uses `DateTime` with start argument for historical date
DateTime.iso8601('1751-04-23', Date::ENGLAND)