ece517-p3/expertiza

View on GitHub
spec/models/assignment_form_spec.rb

Summary

Maintainability
C
1 day
Test Coverage

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

describe AssignmentForm do
  let(:assignment) { build(:assignment, id: 1) }
  let(:due_date) { build(:assignment_due_date) }
  let(:assignment_form) { AssignmentForm.new }
  let(:user) { double('Instructor', timezonepref: 'Eastern Time (US & Canada)') }
Severity: Minor
Found in spec/models/assignment_form_spec.rb by rubocop

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 assignment_form_spec.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe AssignmentForm do
  let(:assignment) { build(:assignment, id: 1) }
  let(:due_date) { build(:assignment_due_date) }
  let(:assignment_form) { AssignmentForm.new }
  let(:user) { double('Instructor', timezonepref: 'Eastern Time (US & Canada)') }
Severity: Minor
Found in spec/models/assignment_form_spec.rb - About 3 hrs to fix

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

      describe '#update_assignment_questionnaires' do
        context 'when attributes are nil' do
          it 'returns false' do
            expect(assignment_form.update_assignment_questionnaires(nil)).to be false
          end
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

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

        context 'when attributes are not nil and at least one assignment_questionnaire\'s id is nil or blank' do
          let(:attributes) { [assignment_questionnaire, assignment_questionnaire2] }
          before(:each) do
            allow(assignment_questionnaire).to receive(:[]).with(:id).and_return(nil)
            allow(assignment_questionnaire).to receive(:[]).with(:questionnaire_weight).and_return(0)
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    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_due_dates' do
        context 'when attributes are nil' do
          it 'returns false' do
            expect(assignment_form.update_due_dates(nil, user)).to be false
          end
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    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 '#add_to_delayed_queue' do
        before(:each) do
          allow(AssignmentDueDate).to receive(:where).with(parent_id: 1).and_return([due_date])
          allow_any_instance_of(AssignmentForm).to receive(:find_min_from_now).with(any_args).and_return(666)
          allow(due_date).to receive(:update_attribute).with(:delayed_job_id, any_args).and_return('Succeed!')
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

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

        context 'when attributes are not nil and at least one due_date\'s id is nil or blank' do
          let(:due_date2) { {due_at: '2015-06-22 12:05:00 -0400'} }
          let(:due_date3) { {id: 1, due_at: '2015-06-22 12:05:00 -0400'} }
          let(:attributes) { [due_date2, due_date3] }
          before(:each) do
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    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 the deadline type is team formation and current assignment is team-based assignment' do
          it 'adds a delayed job and changes the # of DelayedJob by 2' do
            allow(DeadlineType).to receive(:find).with(1).and_return(double('DeadlineType', name: 'team_formation'))
            Sidekiq::Testing.fake!
            Sidekiq::RetrySet.new.clear
    Severity: Major
    Found in spec/models/assignment_form_spec.rb and 1 other location - About 1 hr to fix
    spec/models/assignment_form_spec.rb on lines 157..167

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

    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 the deadline type is review' do
          it 'adds two delayed jobs and changes the # of DelayedJob by 2' do
            allow(DeadlineType).to receive(:find).with(1).and_return(double('DeadlineType', name: 'review'))
            Sidekiq::Testing.fake!
            Sidekiq::RetrySet.new.clear
    Severity: Major
    Found in spec/models/assignment_form_spec.rb and 1 other location - About 1 hr to fix
    spec/models/assignment_form_spec.rb on lines 171..181

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

    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 '#reviews_visible_to_all' do
        context 'when current assignment.reviews_visible_to_all is nil' do
          it 'sets reviews_visible_to_all attribute of current assignment to false' do
            assignment.reviews_visible_to_all = nil
            expect(assignment_form.reviews_visible_to_all).to be false
    Severity: Major
    Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
    spec/models/assignment_form_spec.rb on lines 203..216
    spec/models/assignment_form_spec.rb on lines 221..234
    spec/models/assignment_form_spec.rb on lines 239..252

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

    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 '#availability_flag' do
        context 'when current assignment.availability_flag is nil' do
          it 'sets availability_flag attribute of current assignment to false' do
            assignment.availability_flag = nil
            expect(assignment_form.availability_flag).to be false
    Severity: Major
    Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
    spec/models/assignment_form_spec.rb on lines 203..216
    spec/models/assignment_form_spec.rb on lines 239..252
    spec/models/assignment_form_spec.rb on lines 257..270

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

    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 '#staggered_deadline' do
        context 'when current assignment.staggered_deadlines is nil' do
          it 'sets staggered_deadline attribute of current assignment to false' do
            assignment.staggered_deadline = nil
            expect(assignment_form.staggered_deadline).to be false
    Severity: Major
    Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
    spec/models/assignment_form_spec.rb on lines 221..234
    spec/models/assignment_form_spec.rb on lines 239..252
    spec/models/assignment_form_spec.rb on lines 257..270

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

    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 '#micro_task' do
        context 'when current assignment.microtask is nil' do
          it 'sets microtask attribute of current assignment to false' do
            assignment.microtask = nil
            expect(assignment_form.micro_task).to be false
    Severity: Major
    Found in spec/models/assignment_form_spec.rb and 3 other locations - About 1 hr to fix
    spec/models/assignment_form_spec.rb on lines 203..216
    spec/models/assignment_form_spec.rb on lines 221..234
    spec/models/assignment_form_spec.rb on lines 257..270

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

    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

    Parenthesize the param change { assignment_form.instance_variable_get(:@assignment).availability_flag } to make sure that the block will be associated with the change method call.
    Open

            expect { assignment_form.availability_flag }.not_to change { assignment_form.instance_variable_get(:@assignment).availability_flag }
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    This cop checks for ambiguous block association with method when param passed without parentheses.

    Example:

    # bad
    some_method a { |val| puts val }

    Example:

    # good
    # With parentheses, there's no ambiguity.
    some_method(a) { |val| puts val }
    
    # good
    # Operator methods require no disambiguation
    foo == bar { |b| b.baz }
    
    # good
    # Lambda arguments require no disambiguation
    foo = ->(bar) { bar.baz }

    Parenthesize the param change { assignment_form.instance_variable_get(:@assignment).review_assignment_strategy } to make sure that the block will be associated with the change method call.
    Open

            expect { assignment_form.micro_task }.not_to change { assignment_form.instance_variable_get(:@assignment).review_assignment_strategy }
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    This cop checks for ambiguous block association with method when param passed without parentheses.

    Example:

    # bad
    some_method a { |val| puts val }

    Example:

    # good
    # With parentheses, there's no ambiguity.
    some_method(a) { |val| puts val }
    
    # good
    # Operator methods require no disambiguation
    foo == bar { |b| b.baz }
    
    # good
    # Lambda arguments require no disambiguation
    foo = ->(bar) { bar.baz }

    Do not use Time.parse without zone. Use one of Time.zone.parse, Time.current, Time.parse.in_time_zone, Time.parse.utc, Time.parse.getlocal, Time.parse.iso8601, Time.parse.jisx0301, Time.parse.rfc3339, Time.parse.to_i, Time.parse.to_f instead.
    Open

          due_at = Time.parse(DateTime.new(2017, 10, 7, 12, 12, 12).in_time_zone.to_s(:db))
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    This cop checks for the use of Time methods without zone.

    Built on top of Ruby on Rails style guide (https://github.com/bbatsov/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/ .

    Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

    When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

    Example:

    # always offense
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # no offense
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')
    
    # no offense only if style is 'flexible'
    Time.current
    DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
    Time.at(timestamp).in_time_zone

    Parenthesize the param change { assignment_form.instance_variable_get(:@assignment).staggered_deadline } to make sure that the block will be associated with the change method call.
    Open

            expect { assignment_form.staggered_deadline }.not_to change { assignment_form.instance_variable_get(:@assignment).staggered_deadline }
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    This cop checks for ambiguous block association with method when param passed without parentheses.

    Example:

    # bad
    some_method a { |val| puts val }

    Example:

    # good
    # With parentheses, there's no ambiguity.
    some_method(a) { |val| puts val }
    
    # good
    # Operator methods require no disambiguation
    foo == bar { |b| b.baz }
    
    # good
    # Lambda arguments require no disambiguation
    foo = ->(bar) { bar.baz }

    Parenthesize the param change { assignment_form.instance_variable_get(:@assignment).microtask } to make sure that the block will be associated with the change method call.
    Open

            expect { assignment_form.micro_task }.not_to change { assignment_form.instance_variable_get(:@assignment).microtask }
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    This cop checks for ambiguous block association with method when param passed without parentheses.

    Example:

    # bad
    some_method a { |val| puts val }

    Example:

    # good
    # With parentheses, there's no ambiguity.
    some_method(a) { |val| puts val }
    
    # good
    # Operator methods require no disambiguation
    foo == bar { |b| b.baz }
    
    # good
    # Lambda arguments require no disambiguation
    foo = ->(bar) { bar.baz }

    Prefer Date or Time over DateTime.
    Open

          due_at = Time.parse(DateTime.new(2017, 10, 7, 12, 12, 12).in_time_zone.to_s(:db))
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    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)

    Parenthesize the param change { assignment_form.instance_variable_get(:@assignment).require_quiz } to make sure that the block will be associated with the change method call.
    Open

            expect { assignment_form.require_quiz }.not_to change { assignment_form.instance_variable_get(:@assignment).require_quiz }
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    This cop checks for ambiguous block association with method when param passed without parentheses.

    Example:

    # bad
    some_method a { |val| puts val }

    Example:

    # good
    # With parentheses, there's no ambiguity.
    some_method(a) { |val| puts val }
    
    # good
    # Operator methods require no disambiguation
    foo == bar { |b| b.baz }
    
    # good
    # Lambda arguments require no disambiguation
    foo = ->(bar) { bar.baz }

    Parenthesize the param change { assignment_form.instance_variable_get(:@assignment).reviews_visible_to_all } to make sure that the block will be associated with the change method call.
    Open

            expect { assignment_form.micro_task }.not_to change { assignment_form.instance_variable_get(:@assignment).reviews_visible_to_all }
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    This cop checks for ambiguous block association with method when param passed without parentheses.

    Example:

    # bad
    some_method a { |val| puts val }

    Example:

    # good
    # With parentheses, there's no ambiguity.
    some_method(a) { |val| puts val }
    
    # good
    # Operator methods require no disambiguation
    foo == bar { |b| b.baz }
    
    # good
    # Lambda arguments require no disambiguation
    foo = ->(bar) { bar.baz }

    Prefer Date or Time over DateTime.
    Open

          allow(DateTime).to receive(:now).and_return(DateTime.new(2017, 10, 7, 11, 11, 11).in_time_zone)
    Severity: Minor
    Found in spec/models/assignment_form_spec.rb by rubocop

    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)

    There are no issues that match your filters.

    Category
    Status