diff --git a/.rubocop.yml b/.rubocop.yml
index 371b1967c..c9c2b78fc 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -18,6 +18,9 @@ Layout/CaseIndentation:
Layout/EmptyLineAfterGuardClause:
Enabled: false
+Layout/EmptyLineBetweenDefs:
+ AllowAdjacentOneLineDefs: true
+
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
@@ -44,7 +47,7 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 50
- ExcludedMethods:
+ IgnoredMethods:
- concerning
- context
- should
@@ -66,7 +69,7 @@ Metrics/ModuleLength:
Max: 500
Metrics/ParameterLists:
- Max: 4
+ Max: 6
Metrics/PerceivedComplexity:
Max: 20
@@ -74,18 +77,43 @@ Metrics/PerceivedComplexity:
Lint/InheritException:
EnforcedStyle: standard_error
+Naming/HeredocDelimiterNaming:
+ Enabled: false
+
Naming/MethodParameterName:
Enabled: false
+Naming/PredicateName:
+ Enabled: false
+
+Rails/Blank:
+ UnlessPresent: false
+
+Rails/DynamicFindBy:
+ Enabled: false
+
+Rails/HasManyOrHasOneDependent:
+ Enabled: false
+
Rails/HttpStatus:
EnforcedStyle: numeric
+Rails/InverseOf:
+ Enabled: false
+
+Style/Alias:
+ EnforcedStyle: prefer_alias_method
+
Style/AsciiComments:
Enabled: false
Style/CommentAnnotation:
Enabled: false
+Style/ConditionalAssignment:
+ EnforcedStyle: assign_inside_condition
+ IncludeTernaryExpressions: false
+
Style/Documentation:
Enabled: false
@@ -104,6 +132,9 @@ Style/FloatDivision:
Style/FrozenStringLiteralComment:
Enabled: false
+Style/GuardClause:
+ MinBodyLength: 20
+
Style/HashSyntax:
Enabled: false
@@ -113,12 +144,20 @@ Style/IfUnlessModifier:
Style/MutableConstant:
Enabled: false
+Style/NegatedIf:
+ Enabled: false
+
Style/NumericPredicate:
Enabled: false
Style/PercentLiteralDelimiters:
PreferredDelimiters:
- "default": "[]"
+ "default": "{}"
+ "%i": "[]"
+ "%I": "[]"
+ "%w": "[]"
+ "%W": "[]"
+ "%r": "{}"
Style/ParallelAssignment:
Enabled: false
@@ -134,7 +173,7 @@ Style/SpecialGlobalVars:
Enabled: false
Style/StringLiterals:
- Enabled: false
+ EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
Enabled: false
@@ -142,8 +181,18 @@ Style/StringLiteralsInInterpolation:
Style/SymbolArray:
MinSize: 10
+Style/SymbolProc:
+ IgnoredMethods:
+ - respond_with
+
Style/TernaryParentheses:
EnforcedStyle: require_parentheses_when_complex
+Style/TrailingCommaInArrayLiteral:
+ EnforcedStyleForMultiline: consistent_comma
+
+Style/TrailingCommaInHashLiteral:
+ EnforcedStyleForMultiline: consistent_comma
+
Style/WordArray:
MinSize: 10
diff --git a/app/components/application_component.rb b/app/components/application_component.rb
index b4d8fc1d7..ffc2976c7 100644
--- a/app/components/application_component.rb
+++ b/app/components/application_component.rb
@@ -1,7 +1,6 @@
class ApplicationComponent < ViewComponent::Base
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :external_link_to, :tag_class, to: :helpers
- delegate :edit_icon, :delete_icon, :undelete_icon, :flag_icon, :upvote_icon,
- :downvote_icon, :link_icon, :sticky_icon, :unsticky_icon, to: :helpers
+ delegate :edit_icon, :delete_icon, :undelete_icon, :flag_icon, :upvote_icon, :downvote_icon, :link_icon, :sticky_icon, :unsticky_icon, to: :helpers
def policy(subject)
Pundit.policy!(current_user, subject)
diff --git a/app/components/comment_component.rb b/app/components/comment_component.rb
index b1c4f4d26..7d10555d6 100644
--- a/app/components/comment_component.rb
+++ b/app/components/comment_component.rb
@@ -4,6 +4,7 @@ class CommentComponent < ApplicationComponent
attr_reader :comment, :context, :dtext_data, :current_user
def initialize(comment:, current_user:, context: nil, dtext_data: nil)
+ super
@comment = comment
@context = context
@dtext_data = dtext_data
@@ -11,7 +12,7 @@ class CommentComponent < ApplicationComponent
end
def dimmed?
- comment.is_deleted? || (!comment.is_sticky? && comment.score <= current_user.comment_threshold/2.0)
+ comment.is_deleted? || (!comment.is_sticky? && comment.score <= current_user.comment_threshold / 2.0)
end
def thresholded?
diff --git a/app/components/comment_section_component.rb b/app/components/comment_section_component.rb
index cc8bf85d0..5c3110bc0 100644
--- a/app/components/comment_section_component.rb
+++ b/app/components/comment_section_component.rb
@@ -4,6 +4,7 @@ class CommentSectionComponent < ApplicationComponent
attr_reader :post, :comments, :current_user, :limit, :dtext_data
def initialize(post:, current_user:, limit: nil)
+ super
@post = post
@current_user = current_user
@limit = limit
diff --git a/app/components/forum_post_component.rb b/app/components/forum_post_component.rb
index 855b8b3bd..ccf1a7577 100644
--- a/app/components/forum_post_component.rb
+++ b/app/components/forum_post_component.rb
@@ -2,6 +2,7 @@
class ForumPostComponent < ApplicationComponent
attr_reader :forum_post, :original_forum_post_id, :dtext_data, :moderation_reports, :current_user
+
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :policy, to: :helpers
with_collection_parameter :forum_post
@@ -17,6 +18,7 @@ class ForumPostComponent < ApplicationComponent
end
def initialize(forum_post:, original_forum_post_id: nil, dtext_data: nil, current_user: User.anonymous)
+ super
@forum_post = forum_post
@original_forum_post_id = original_forum_post_id
@dtext_data = dtext_data
diff --git a/app/components/forum_post_component/forum_post_component.html.erb b/app/components/forum_post_component/forum_post_component.html.erb
index fde6055df..7690d7ed9 100644
--- a/app/components/forum_post_component/forum_post_component.html.erb
+++ b/app/components/forum_post_component/forum_post_component.html.erb
@@ -23,6 +23,7 @@
<% if policy(forum_post).create? %>
<%= link_to "Reply", new_forum_post_path(post_id: forum_post.id), method: :get, remote: true %>
<% end %>
+
<% if policy(forum_post).destroy? && !forum_post.is_original_post?(original_forum_post_id) %>
<% if forum_post.is_deleted %>
<%= link_to "Undelete", undelete_forum_post_path(forum_post.id), method: :post, remote: true %>
@@ -30,6 +31,7 @@
<%= link_to "Delete", forum_post_path(forum_post.id), "data-confirm": "Are you sure you want to delete this forum post?", method: :delete, remote: true %>
<% end %>
<% end %>
+
<% if policy(forum_post).update? %>
<% if forum_post.is_original_post?(original_forum_post_id) %>
<%= link_to "Edit", edit_forum_topic_path(forum_post.topic), id: "edit_forum_topic_link_#{forum_post.topic.id}", class: "edit_forum_topic_link" %>
@@ -37,12 +39,15 @@
<%= link_to "Edit", edit_forum_post_path(forum_post.id), id: "edit_forum_post_link_#{forum_post.id}", class: "edit_forum_post_link" %>
<% end %>
<% end %>
+
<% if policy(forum_post).reportable? %>
<%= link_to "Report", new_moderation_report_path(moderation_report: { model_type: "ForumPost", model_id: forum_post.id }), remote: true, title: "Report this forum post to the moderators" %>
<% end %>
+
<% if has_moderation_reports? %>
Reported (<%= link_to pluralize(forum_post.moderation_reports.length, "report"), moderation_reports_path(search: { model_type: "ForumPost", model_id: forum_post.id }) %>)
<% end %>
+
<% if forum_post.bulk_update_request.present? %>