ece517-p3/expertiza

View on GitHub
spec/models/answer_spec.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

describe Answer do
  let(:questionnaire) { create(:questionnaire, id: 1) }
  let(:question1) { create(:question, questionnaire: questionnaire, weight: 1, id: 1) }
  let(:question2) { create(:question, questionnaire: questionnaire, weight: 2, id: 2) }
  let(:response_map) { create(:review_response_map, id: 1, reviewed_object_id: 1) }
Severity: Minor
Found in spec/models/answer_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. [53/25]
Open

  describe "#test compute scores" do
    let(:response1) { double("respons1") }
    let(:response2) { double("respons2") }

    before(:each) do
Severity: Minor
Found in spec/models/answer_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

  describe "#test get total score" do
    it "returns total score when required conditions are met" do
      # stub for ScoreView.find_by_sql to revent prevent unit testing sql db queries
      allow(ScoreView).to receive(:find_by_sql).and_return([double("scoreview", weighted_score: 20, sum_of_weights: 5, q1_max_question_score: 4)])
      allow(Answer).to receive(:where).and_return([double("row1", question_id: 1, answer: "1")])
Severity: Minor
Found in spec/models/answer_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.

(...) interpreted as grouped expression.
Open

      expect(scores[:avg]).to eq (total_score1 + total_score2) / 2
Severity: Minor
Found in spec/models/answer_spec.rb by rubocop

Checks for space between the name of a called method and a left parenthesis.

Example:

# bad

puts (x + y)

Example:

# good

puts(x + y)

Ambiguous negative number operator. Parenthesize the method arguments if it's surely a negative number operator, or add a whitespace to the right of the - if it should be a subtraction.
Open

      expect(Answer.get_total_score(response: [response_record], questions: [question1])).to eq -1.0
Severity: Minor
Found in spec/models/answer_spec.rb by rubocop

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

Example:

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

Example:

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

Ambiguous negative number operator. Parenthesize the method arguments if it's surely a negative number operator, or add a whitespace to the right of the - if it should be a subtraction.
Open

      expect(Answer.get_total_score(response: [response_record], questions: [question1])).to eq -1.0
Severity: Minor
Found in spec/models/answer_spec.rb by rubocop

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

Example:

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

Example:

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

Useless assignment to variable - scores.
Open

      scores = Answer.compute_scores(assessments, [question1])
Severity: Minor
Found in spec/models/answer_spec.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

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

      ResubmissionTime1 = Time.new - 24
Severity: Minor
Found in spec/models/answer_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

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

      ResubmissionTime2 = Time.new - 48
Severity: Minor
Found in spec/models/answer_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

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

      due_date2.due_at = Time.new - 24
Severity: Minor
Found in spec/models/answer_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

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

      due_date1.due_at = Time.new - 24
Severity: Minor
Found in spec/models/answer_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

There are no issues that match your filters.

Category
Status