From 51fee5992e607dcd5618db6a66982931831a1a8f Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:17:13 +0100
Subject: [PATCH 01/18] Fix rubocop offense in wiki_helper
---
app/helpers/wiki_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb
index 76657f653c..925bfdd0e4 100644
--- a/app/helpers/wiki_helper.rb
+++ b/app/helpers/wiki_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module WikiHelper
end
From 018ac17d51b03327dc97260324b93928dfadddcc Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:18:11 +0100
Subject: [PATCH 02/18] Fix rubocop offense in users_helper
---
app/helpers/users_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 2310a240d7..4dc909ed69 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module UsersHelper
end
From cf2c88b3b61426be585f5c349c01eb8ae10d92fc Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:19:11 +0100
Subject: [PATCH 03/18] Fix rubocop offense in user_tags_helper
---
app/helpers/user_tags_helper.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/helpers/user_tags_helper.rb b/app/helpers/user_tags_helper.rb
index e15e57f3bb..a433633273 100644
--- a/app/helpers/user_tags_helper.rb
+++ b/app/helpers/user_tags_helper.rb
@@ -1,6 +1,8 @@
+# frozen_string_literal: true
+
module UserTagsHelper
def fetch_tags(uid, type)
- tag_types = %w(skill gear role tool)
+ tag_types = %w[skill gear role tool]
tags = []
if tag_types.include? type
tags = UserTag.where(uid: uid).where('value LIKE ?', type + ':' + '%')
From c2d76c72dd75f344f85fdb66a37b8a085756d27f Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:19:41 +0100
Subject: [PATCH 04/18] Fix rubocop offense in tag_helper
---
app/helpers/tag_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/tag_helper.rb b/app/helpers/tag_helper.rb
index 568c90f7fd..af940e0f2b 100644
--- a/app/helpers/tag_helper.rb
+++ b/app/helpers/tag_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module TagHelper
end
From ce899a3e89b2d54211db8d822c532ee7931f13ac Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:23:52 +0100
Subject: [PATCH 05/18] Fix rubocop offenses in search_helper
---
app/helpers/search_helper.rb | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index b9a4e4bd37..132ebaa025 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -1,17 +1,19 @@
+# frozen_string_literal: true
+
module SearchHelper
def create_nav_links(active_page, query)
links = [
- { section: "search-all", text: "Content", path: "/search/#{query}" },
- { section: "search-profiles", text: "People", path: "/search/profiles/#{query}" }
+ { section: 'search-all', text: 'Content', path: "/search/#{query}" },
+ { section: 'search-profiles', text: 'People', path: "/search/profiles/#{query}" }
]
- result = ""
+ result = ''
links.each do |link|
active_link =
if active_page == link[:section]
- "list-group-item list-group-item-action active"
+ 'list-group-item list-group-item-action active'
else
- "list-group-item list-group-item-action"
+ 'list-group-item list-group-item-action'
end
result += "
#{link[:text]} "
end
@@ -20,19 +22,19 @@ def create_nav_links(active_page, query)
def create_nav_links_for_by_type(active_page, query)
links = [
- { section: "search-all", text: "All content types", path: "/search/content/#{query}" },
- { section: "search-questions", text: "Questions", path: "/search/questions/#{query}" },
- { section: "search-notes", text: "Notes", path: "/search/notes/#{query}" },
- { section: "search-wikis", text: "Wikis", path: "/search/wikis/#{query}" }
+ { section: 'search-all', text: 'All content types', path: "/search/content/#{query}" },
+ { section: 'search-questions', text: 'Questions', path: "/search/questions/#{query}" },
+ { section: 'search-notes', text: 'Notes', path: "/search/notes/#{query}" },
+ { section: 'search-wikis', text: 'Wikis', path: "/search/wikis/#{query}" }
]
- result = ""
+ result = ''
links.each do |link|
active_link =
if active_page == link[:section]
- "dropdown-item active"
+ 'dropdown-item active'
else
- "dropdown-item"
+ 'dropdown-item'
end
result += " #{link[:text]}"
end
From 42bede039aefa55f0595365162ec746d4b95a63e Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:24:45 +0100
Subject: [PATCH 06/18] Fix rubocop offense in redirect_helper
---
app/helpers/redirect_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/redirect_helper.rb b/app/helpers/redirect_helper.rb
index 31328b7453..b01d95688c 100644
--- a/app/helpers/redirect_helper.rb
+++ b/app/helpers/redirect_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module RedirectHelper
end
From e8055743418ed1a515f4c4d4d37878ee9e43829f Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:25:21 +0100
Subject: [PATCH 07/18] Fix rubocop offense in openid_helper
---
app/helpers/openid_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/openid_helper.rb b/app/helpers/openid_helper.rb
index 9175552cac..1ad649b29b 100644
--- a/app/helpers/openid_helper.rb
+++ b/app/helpers/openid_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module OpenidHelper
def url_for_user
'/profile/' + current_user.username
From a6e97ef8a43d51e2f681c56804494b11e5b4c0f1 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:25:55 +0100
Subject: [PATCH 08/18] Fix rubocop offense in notes_helper
---
app/helpers/notes_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb
index 8078f73032..7e783c902a 100644
--- a/app/helpers/notes_helper.rb
+++ b/app/helpers/notes_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module NotesHelper
end
From 36a92b1534da2f742d6146d3773156c8efb3dbfc Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:26:21 +0100
Subject: [PATCH 09/18] Fix rubocop offense in map_helper
---
app/helpers/map_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/map_helper.rb b/app/helpers/map_helper.rb
index 65a9561697..a5944770c8 100644
--- a/app/helpers/map_helper.rb
+++ b/app/helpers/map_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module MapHelper
end
From c61df2a4ba4260b9fb72577c9e7507c750ead0b8 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:26:51 +0100
Subject: [PATCH 10/18] Fix rubocop offense in home_helper
---
app/helpers/home_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb
index 23de56ac60..03620959cd 100644
--- a/app/helpers/home_helper.rb
+++ b/app/helpers/home_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module HomeHelper
end
From 4cc1511d58146480a598cfe5b8e22f4b1e74ddb7 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:27:14 +0100
Subject: [PATCH 11/18] Fix rubocop offense in csvfiles_helper
---
app/helpers/csvfiles_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/csvfiles_helper.rb b/app/helpers/csvfiles_helper.rb
index 41fa09cf45..b6d68fed24 100644
--- a/app/helpers/csvfiles_helper.rb
+++ b/app/helpers/csvfiles_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module CsvfilesHelper
end
From 8a87dabdceab20f577fa4e04e58138d1b941cd06 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:39:14 +0100
Subject: [PATCH 12/18] Fix rubocop offenses in application_helper
---
app/helpers/application_helper.rb | 56 ++++++++++++++-----------------
1 file changed, 26 insertions(+), 30 deletions(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4cf72d6321..b9146c45a2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module ApplicationHelper
# returns true if user is logged in and has any of the roles given, as ['admin','moderator']
def logged_in_as(roles)
@@ -7,13 +9,13 @@ def logged_in_as(roles)
end
def emojify(content)
- if content.present?
- content.to_str.gsub(/:([\w+-]+):(?![^\[]*\])/) do |match|
- if emoji = Emoji.find_by_alias(Regexp.last_match(1))
- emoji.raw || %(
)
- else
- match
- end
+ return unless content.present?
+
+ content.to_str.gsub(/:([\w+-]+):(?![^\[]*\])/) do |match|
+ if (emoji = Emoji.find_by_alias(Regexp.last_match(1)))
+ emoji.raw || %(
)
+ else
+ match
end
end
end
@@ -32,34 +34,30 @@ def emoji_names_list
end
def emoji_info
- emoji_names = ["thumbs-up", "thumbs-down", "laugh", "hooray", "confused", "heart"]
+ emoji_names = %w[thumbs-up thumbs-down laugh hooray confused heart]
emoji_image_map = {
- "thumbs-up" => "https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png",
- "thumbs-down" => "https://github.githubassets.com/images/icons/emoji/unicode/1f44e.png",
- "laugh" => "https://github.githubassets.com/images/icons/emoji/unicode/1f604.png",
- "hooray" => "https://github.githubassets.com/images/icons/emoji/unicode/1f389.png",
- "confused" => "https://github.githubassets.com/images/icons/emoji/unicode/1f615.png",
- "heart" => "https://github.githubassets.com/images/icons/emoji/unicode/2764.png"
+ 'thumbs-up' => 'https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png',
+ 'thumbs-down' => 'https://github.githubassets.com/images/icons/emoji/unicode/1f44e.png',
+ 'laugh' => 'https://github.githubassets.com/images/icons/emoji/unicode/1f604.png',
+ 'hooray' => 'https://github.githubassets.com/images/icons/emoji/unicode/1f389.png',
+ 'confused' => 'https://github.githubassets.com/images/icons/emoji/unicode/1f615.png',
+ 'heart' => 'https://github.githubassets.com/images/icons/emoji/unicode/2764.png'
}
[emoji_names, emoji_image_map]
end
def feature(title)
features = Node.where(type: 'feature', title: title)
- if !features.empty?
- return features.last.body.to_s.html_safe
- else
- ''
- end
+ return features.last.body.to_s.html_safe unless features.empty?
+
+ ''
end
def feature_node(title)
features = Node.where(type: 'feature', title: title)
- if !features.empty?
- return features.last
- else
- ''
- end
+ return features.last unless features.empty?
+
+ ''
end
def locale_name_pairs
@@ -101,11 +99,11 @@ def render_top_map(lat, lon)
# we should move this to the Comment model:
# replaces inline title suggestion(e.g: {New Title}) with the required link to change the title
def title_suggestion(comment)
- comment.body.gsub(/\[propose:title\](.*?)\[\/propose\]/) do
+ comment.body.gsub(%r{\[propose:title\](.*?)\[/propose\]}) do
a = ActionController::Base.new
is_creator = ((defined? current_user) && current_user == Node.find(comment.nid).author) == true
title = Regexp.last_match(1)
- output = a.render_to_string(template: "notes/_title_suggestion",
+ output = a.render_to_string(template: 'notes/_title_suggestion',
layout: false,
locals: {
user: comment.user.name,
@@ -118,9 +116,7 @@ def title_suggestion(comment)
end
def filtered_comment_body(comment_body)
- if contain_trimmed_body?(comment_body)
- return comment_body.split(Comment::COMMENT_FILTER).first
- end
+ return comment_body.split(Comment::COMMENT_FILTER).first if contain_trimmed_body?(comment_body)
comment_body
end
@@ -142,7 +138,7 @@ def translation(key, options = {})
options[:fallback] = false
translated_string2 = t(key, options)
- if current_user&.has_tag('translation-helper') && translated_string2.include?("translation missing") && !translated_string.include?("<")
+ if current_user&.has_tag('translation-helper') && translated_string2.include?('translation missing') && !translated_string.include?('<')
%(#{translated_string}
)
From 8fd34bb9c634cb5625e5393ac28b89dfc929fb20 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:41:59 +0100
Subject: [PATCH 13/18] Fix Style/IfUnlessModifier offense in user_tags_helper
---
app/helpers/user_tags_helper.rb | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/app/helpers/user_tags_helper.rb b/app/helpers/user_tags_helper.rb
index a433633273..890b68eced 100644
--- a/app/helpers/user_tags_helper.rb
+++ b/app/helpers/user_tags_helper.rb
@@ -4,9 +4,7 @@ module UserTagsHelper
def fetch_tags(uid, type)
tag_types = %w[skill gear role tool]
tags = []
- if tag_types.include? type
- tags = UserTag.where(uid: uid).where('value LIKE ?', type + ':' + '%')
- end
+ tags = UserTag.where(uid: uid).where('value LIKE ?', type + ':' + '%') if tag_types.include? type
tags
end
end
From 08a819e4397aa9dd0b2c88e6c8f2847dac25c965 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:42:47 +0100
Subject: [PATCH 14/18] Fix rubocop offense in features_helper
---
app/helpers/features_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/features_helper.rb b/app/helpers/features_helper.rb
index 1a5e6b20fc..1c223823f3 100644
--- a/app/helpers/features_helper.rb
+++ b/app/helpers/features_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module FeaturesHelper
end
From b85b3128a153c332eb1ffa97f13a2d1f623de4fc Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:44:48 +0100
Subject: [PATCH 15/18] Fix rubocop offenses in comment_helper
---
app/helpers/comment_helper.rb | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/app/helpers/comment_helper.rb b/app/helpers/comment_helper.rb
index 35fe3c169c..c94e0ee7be 100644
--- a/app/helpers/comment_helper.rb
+++ b/app/helpers/comment_helper.rb
@@ -1,14 +1,13 @@
+# frozen_string_literal: true
+
module CommentHelper
class CommentError < ArgumentError
end
def create_comment(node, user, body)
@comment = node.add_comment(uid: user.uid, body: body)
- if user && @comment.save
- @comment.notify user
- return @comment
- else
- raise CommentError
- end
+ raise CommentError unless user && @comment.save
+
+ @comment
end
end
From a600d68e0158f25e26dd834449eae810719d22f1 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:45:25 +0100
Subject: [PATCH 16/18] Fix rubocop offense in admin_helper
---
app/helpers/admin_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index d5c6d3555d..c79cbfc102 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
module AdminHelper
end
From 28b8de6e88d71e3cf02b29a93a1d067bcd1ee430 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 12:56:56 +0100
Subject: [PATCH 17/18] Codeclimate prefers parentheses
---
app/helpers/application_helper.rb | 2 +-
app/helpers/user_tags_helper.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b9146c45a2..e6eaa7189e 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -34,7 +34,7 @@ def emoji_names_list
end
def emoji_info
- emoji_names = %w[thumbs-up thumbs-down laugh hooray confused heart]
+ emoji_names = %w(thumbs-up thumbs-down laugh hooray confused heart)
emoji_image_map = {
'thumbs-up' => 'https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png',
'thumbs-down' => 'https://github.githubassets.com/images/icons/emoji/unicode/1f44e.png',
diff --git a/app/helpers/user_tags_helper.rb b/app/helpers/user_tags_helper.rb
index 890b68eced..ff00de97e4 100644
--- a/app/helpers/user_tags_helper.rb
+++ b/app/helpers/user_tags_helper.rb
@@ -2,7 +2,7 @@
module UserTagsHelper
def fetch_tags(uid, type)
- tag_types = %w[skill gear role tool]
+ tag_types = %w(skill gear role tool)
tags = []
tags = UserTag.where(uid: uid).where('value LIKE ?', type + ':' + '%') if tag_types.include? type
tags
From 6c87f5e2127bcccd8c9f36ed82f040a7a843c7c7 Mon Sep 17 00:00:00 2001
From: Jade Dickinson <14929975+JadeDickinson@users.noreply.github.com>
Date: Fri, 11 Oct 2019 13:27:57 +0100
Subject: [PATCH 18/18] Put back an accidentally removed line
---
app/helpers/comment_helper.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/helpers/comment_helper.rb b/app/helpers/comment_helper.rb
index c94e0ee7be..ee4b5007aa 100644
--- a/app/helpers/comment_helper.rb
+++ b/app/helpers/comment_helper.rb
@@ -8,6 +8,7 @@ def create_comment(node, user, body)
@comment = node.add_comment(uid: user.uid, body: body)
raise CommentError unless user && @comment.save
+ @comment.notify user
@comment
end
end