Skip to content

Commit

Permalink
DEV: Fix new Rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Flink committed Mar 6, 2024
1 parent e54aeee commit b2cf221
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 62 deletions.
39 changes: 32 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,45 +1,70 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
drb (2.2.1)
i18n (1.14.3)
concurrent-ruby (~> 1.0)
racc (~> 1.7)
json (2.7.1)
language_server-protocol (3.17.0.3)
minitest (5.22.2)
mutex_m (0.2.0)
parallel (1.24.0)
parser (3.3.0.4)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.60.0)
rubocop (1.62.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-ast (1.31.1)
parser (>= 3.3.0.4)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-discourse (3.6.0)
rubocop-discourse (3.7.1)
activesupport (>= 6.1)
rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0)
rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-rspec (2.26.1)
rubocop-rspec (2.27.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)

PLATFORMS
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/post_voting/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module PostVoting
class CommentsController < ::ApplicationController
requires_plugin PLUGIN_NAME

before_action :find_post, only: %i[load_more_comments create]
before_action :ensure_post_voting_enabled, only: %i[load_more_comments create]
before_action :ensure_logged_in, only: %i[create destroy update]
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/post_voting/votes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module PostVoting
class VotesController < ::ApplicationController
requires_plugin PLUGIN_NAME

before_action :ensure_logged_in
before_action :find_vote_post, only: %i[create destroy voters]
before_action :ensure_can_see_post, only: %i[create destroy voters]
Expand Down
54 changes: 28 additions & 26 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,35 @@

enabled_site_setting :post_voting_enabled

module ::PostVoting
PLUGIN_NAME = "discourse-post-voting"
end

after_initialize do
%w[
../lib/post_voting/engine.rb
../lib/post_voting/vote_manager.rb
../lib/post_voting/guardian_extension.rb
../lib/post_voting/comment_creator.rb
../lib/post_voting/comment_review_queue.rb
../extensions/post_extension.rb
../extensions/post_serializer_extension.rb
../extensions/topic_extension.rb
../extensions/topic_list_item_serializer_extension.rb
../extensions/topic_view_serializer_extension.rb
../extensions/topic_view_extension.rb
../extensions/user_extension.rb
../extensions/composer_messages_finder_extension.rb
../app/validators/post_voting_comment_validator.rb
../app/controllers/post_voting/votes_controller.rb
../app/controllers/post_voting/comments_controller.rb
../app/models/post_voting_vote.rb
../app/models/post_voting_comment.rb
../app/models/post_voting_comment_custom_field.rb
../app/models/reviewable_post_voting_comment.rb
../app/serializers/basic_voter_serializer.rb
../app/serializers/post_voting_comment_serializer.rb
../app/serializers/reviewable_post_voting_comments_serializer.rb
../config/routes.rb
].each { |path| load File.expand_path(path, __FILE__) }
require_relative "lib/post_voting/engine"
require_relative "lib/post_voting/vote_manager"
require_relative "lib/post_voting/guardian_extension"
require_relative "lib/post_voting/comment_creator"
require_relative "lib/post_voting/comment_review_queue"
require_relative "extensions/post_extension"
require_relative "extensions/post_serializer_extension"
require_relative "extensions/topic_extension"
require_relative "extensions/topic_list_item_serializer_extension"
require_relative "extensions/topic_view_serializer_extension"
require_relative "extensions/topic_view_extension"
require_relative "extensions/user_extension"
require_relative "extensions/composer_messages_finder_extension"
require_relative "app/validators/post_voting_comment_validator"
require_relative "app/controllers/post_voting/votes_controller"
require_relative "app/controllers/post_voting/comments_controller"
require_relative "app/models/post_voting_vote"
require_relative "app/models/post_voting_comment"
require_relative "app/models/post_voting_comment_custom_field"
require_relative "app/models/reviewable_post_voting_comment"
require_relative "app/serializers/basic_voter_serializer"
require_relative "app/serializers/post_voting_comment_serializer"
require_relative "app/serializers/reviewable_post_voting_comments_serializer"
require_relative "config/routes"

if respond_to?(:register_svg_icon)
register_svg_icon "angle-up"
Expand Down
4 changes: 2 additions & 2 deletions spec/components/composer_messages_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

describe ComposerMessagesFinder do
describe ".check_sequential_replies" do
fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) }
fab!(:user)
fab!(:topic)
fab!(:post_voting_topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/components/post_voting/vote_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

describe PostVoting::VoteManager do
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:user_2) { Fabricate(:user) }
fab!(:user_3) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/email/receiver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def process(email_name, opts = {})

describe "reply" do
let(:reply_key) { "4f97315cc828096c9cb34c6f1a0d6fe8" }
fab!(:category) { Fabricate(:category) }
fab!(:category)
fab!(:user) { Fabricate(:user, email: "[email protected]", refresh_auto_groups: true) }
fab!(:topic) do
create_topic(category: category, user: user, subtype: Topic::POST_VOTING_SUBTYPE)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/topic_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require "rails_helper"

describe TopicView do
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:user)
fab!(:admin)
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:post) { create_post(topic: topic) }

Expand Down
4 changes: 2 additions & 2 deletions spec/models/post_voting_comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
describe PostVotingComment do
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:user) { Fabricate(:user) }
fab!(:tag) { Fabricate(:tag) }
fab!(:user)
fab!(:tag)

before { SiteSetting.post_voting_enabled = true }

Expand Down
4 changes: 2 additions & 2 deletions spec/models/post_voting_vote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:topic_post) { Fabricate(:post, topic: topic) }
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:post_1) { Fabricate(:post, topic: topic, user: user) }
fab!(:tag) { Fabricate(:tag) }
fab!(:tag)

before { SiteSetting.post_voting_enabled = true }

Expand Down
4 changes: 2 additions & 2 deletions spec/models/topic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require "rails_helper"

describe Topic do
fab!(:user) { Fabricate(:user) }
fab!(:category) { Fabricate(:category) }
fab!(:user)
fab!(:category)
fab!(:topic) { Fabricate(:topic, category: category, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:topic_post) { Fabricate(:post, topic: topic) }

Expand Down
6 changes: 3 additions & 3 deletions spec/requests/list_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
require "rails_helper"

describe ListController do
fab!(:user) { Fabricate(:user) }
fab!(:category) { Fabricate(:category) }
fab!(:user)
fab!(:category)
fab!(:post_voting_topic) do
Fabricate(:topic, category: category, subtype: Topic::POST_VOTING_SUBTYPE)
end
fab!(:post_voting_topic_post) { Fabricate(:post, topic: post_voting_topic) }
fab!(:post_voting_topic_answer) { create_post(topic: post_voting_topic, reply_to_post: nil) }
fab!(:topic) { Fabricate(:topic) }
fab!(:topic)

before do
SiteSetting.post_voting_enabled = true
Expand Down
10 changes: 5 additions & 5 deletions spec/requests/post_voting/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
require "rails_helper"

RSpec.describe PostVoting::CommentsController do
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:moderator) { Fabricate(:moderator) }
fab!(:group) { Fabricate(:group) }
fab!(:category) { Fabricate(:category) }
fab!(:user)
fab!(:admin)
fab!(:moderator)
fab!(:group)
fab!(:category)
fab!(:topic) { Fabricate(:topic, category: category, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:topic_post) { Fabricate(:post, topic: topic) }
fab!(:answer) { Fabricate(:post, topic: topic) }
Expand Down
8 changes: 4 additions & 4 deletions spec/requests/post_voting/votes_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
require "rails_helper"

RSpec.describe PostVoting::VotesController do
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:topic_post) { Fabricate(:post, topic: topic) }
fab!(:answer) { Fabricate(:post, topic: topic) }
fab!(:answer_2) { Fabricate(:post, topic: topic) }
fab!(:answer_3) { Fabricate(:post, topic: topic, user: user) }

fab!(:admin) { Fabricate(:admin) }
fab!(:category) { Fabricate(:category) }
fab!(:admin)
fab!(:category)

before { SiteSetting.post_voting_enabled = true }

Expand Down Expand Up @@ -145,7 +145,7 @@
end

describe "#voters" do
fab!(:user) { Fabricate(:user) }
fab!(:user)

it "should return the right response for an anon user" do
get "/post_voting/voters.json", params: { post_id: answer.id }
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/topics_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

describe TopicsController do
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:post) { create_post(topic: topic) }
fab!(:comment) { Fabricate(:post_voting_comment, raw: "this is a comment!", post: post) }
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/basic_category_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

describe BasicCategorySerializer do
fab!(:category) { Fabricate(:category) }
fab!(:category)

let(:serialized) do
serializer = BasicCategorySerializer.new(category, root: false)
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/post_voting/comment_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe PostVotingCommentSerializer do
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:comment) { Fabricate(:post_voting_comment, post: post) }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/post_voting/post_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

describe PostVoting::PostSerializerExtension do
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }
fab!(:topic_post) { Fabricate(:post, topic: topic) }
fab!(:answer) { Fabricate(:post, topic: topic) }
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/post_voting/topic_view_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
fab!(:topic_post) { Fabricate(:post, topic: topic) }
fab!(:answer) { Fabricate(:post, topic: topic, reply_to_post_number: nil) }
fab!(:comment) { Fabricate(:post_voting_comment, post: answer) }
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:guardian) { Guardian.new(user) }
let(:topic_view) { TopicView.new(topic, user) }

Expand Down

0 comments on commit b2cf221

Please sign in to comment.