Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
raccube committed Nov 27, 2023
1 parent b55e6da commit 8facb44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/discover_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def index

top_x = 10 # only display the top X items

@popular_answers = Answer.for_user(current_user).where("created_at > ?", Time.now.ago(1.week)).order(:smile_count).reverse_order.limit(top_x).includes(:question, :user, :comments)
@most_discussed = Answer.for_user(current_user).where("created_at > ?", Time.now.ago(1.week)).order(:comment_count).reverse_order.limit(top_x).includes(:question, :user, :comments)
@popular_answers = Answer.for_user(current_user).where("created_at > ?", Time.now.utc.ago(1.week)).order(:smile_count).reverse_order.limit(top_x).includes(:question, :user, :comments)
@most_discussed = Answer.for_user(current_user).where("created_at > ?", Time.now.utc.ago(1.week)).order(:comment_count).reverse_order.limit(top_x).includes(:question, :user, :comments)

Check warning on line 12 in app/controllers/discover_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/discover_controller.rb#L11-L12

Added lines #L11 - L12 were not covered by tests
@popular_questions = Question.where("created_at > ?", Time.now.ago(1.week)).order(:answer_count).reverse_order.limit(top_x).includes(:user)
@new_users = User.where("asked_count > 0").order(:id).reverse_order.limit(top_x).includes(:profile)

Expand All @@ -25,7 +25,7 @@ def index
# .user = the user
# .answer_count = how many questions did the user answer
@users_with_most_answers = Answer.select('user_id, COUNT(*) AS answer_count').
where("created_at > ?", Time.now.ago(1.week)).
where("created_at > ?", week_ago).

Check notice on line 28 in app/controllers/discover_controller.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/controllers/discover_controller.rb#L28 <Layout/MultilineMethodCallIndentation>

Align `where` with `Answer.select('user_id, COUNT(*) AS answer_count').` on line 27.
Raw output
app/controllers/discover_controller.rb:28:9: C: Layout/MultilineMethodCallIndentation: Align `where` with `Answer.select('user_id, COUNT(*) AS answer_count').` on line 27.

Check notice on line 28 in app/controllers/discover_controller.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/controllers/discover_controller.rb#L28 <Layout/DotPosition>

Place the . on the next line, together with the method name.
Raw output
app/controllers/discover_controller.rb:28:42: C: Layout/DotPosition: Place the . on the next line, together with the method name.
group(:user_id).
order('answer_count').
reverse_order.limit(top_x)
Expand Down
3 changes: 2 additions & 1 deletion app/models/answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Answer < ApplicationRecord
FROM reactions
WHERE parent_id = answers.id
AND parent_type = 'Answer'
AND user_id = #{current_user.id}) as has_reacted")
AND user_id = #{current_user.id}) as has_reacted",
)

Check notice on line 31 in app/models/answer.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/models/answer.rb#L31 <Layout/ClosingParenthesisIndentation>

Align `)` with `(`.
Raw output
app/models/answer.rb:31:12: C: Layout/ClosingParenthesisIndentation: Align `)` with `(`.

Check notice on line 31 in app/models/answer.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] app/models/answer.rb#L31 <Layout/MultilineMethodCallBraceLayout>

Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument.
Raw output
app/models/answer.rb:31:12: C: Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument.
}

SHORT_ANSWER_MAX_LENGTH = 640
Expand Down

0 comments on commit 8facb44

Please sign in to comment.