From 2c29976ed2935c7fdbbff5c9cf621da66d07387c Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Thu, 13 Jul 2023 07:45:20 +0200 Subject: [PATCH] rubocop --- _plugins/author-page.rb | 8 ++++++-- _plugins/jekyll-duration.rb | 2 +- bin/lint.rb | 25 +++++++++++++------------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/_plugins/author-page.rb b/_plugins/author-page.rb index 2cbceada5ee568..f0db6a1f649887 100644 --- a/_plugins/author-page.rb +++ b/_plugins/author-page.rb @@ -103,9 +103,13 @@ def generate(site) page2.data['news_count'] = news_by_author[contributor].length page2.data['learning_pathways_count'] = learning_pathways_by_author[contributor].length - page2.data['editors'] = TopicFilter.enumerate_topics(site).select {|t| t.fetch('editorial_board', []).include?(contributor) } + page2.data['editors'] = TopicFilter.enumerate_topics(site).select do |t| + t.fetch('editorial_board', []).include?(contributor) + end # Also their learning pathways - page2.data['editors'] += site.pages.select {|t| t['layout'] == 'learning-pathway' && t.data.fetch('editorial_board', []).include?(contributor) } + page2.data['editors'] += site.pages.select do |t| + t['layout'] == 'learning-pathway' && t.data.fetch('editorial_board', []).include?(contributor) + end page2.data['editor_count'] = page2.data['editors'].length page2.data['has_philosophy'] = has_philosophy[contributor] diff --git a/_plugins/jekyll-duration.rb b/_plugins/jekyll-duration.rb index 008be2883960ad..a0a1f8b225d309 100644 --- a/_plugins/jekyll-duration.rb +++ b/_plugins/jekyll-duration.rb @@ -29,7 +29,7 @@ def duration_to_human(duration) hour = 'hour' hours = 'hours' minutes = 'minutes' - if @context.registers[:page]&.key?('lang') and @context.registers[:page]['lang'] != 'en' + if @context.registers[:page]&.key?('lang') && (@context.registers[:page]['lang'] != 'en') lang = @context.registers[:page]['lang'] hour = @context.registers[:site].data['lang'][lang]['hour'] hours = @context.registers[:site].data['lang'][lang]['hours'] diff --git a/bin/lint.rb b/bin/lint.rb index 327e9a560c1e3c..043754c646aaf3 100755 --- a/bin/lint.rb +++ b/bin/lint.rb @@ -108,7 +108,7 @@ def self.message(path: '', idx: 0, match_start: 0, match_end: 1, replacement: ni # Linting functions for the GTN module GtnLinter @BAD_TOOL_LINK = /{% tool (\[[^\]]*\])\(https?.*tool_id=([^)]*)\)\s*%}/i - @BAD_TOOL_LINK2 = /{% tool (\[[^\]]*\])\(https:\/\/toolshed.g2([^)]*)\)\s*%}/i + @BAD_TOOL_LINK2 = %r{{% tool (\[[^\]]*\])\(https://toolshed.g2([^)]*)\)\s*%}}i def self.find_matching_texts(contents, query) contents.map.with_index do |text, idx| @@ -350,18 +350,19 @@ def self.non_existent_snippet(contents) end def self.bad_tool_links(contents) - find_matching_texts(contents, @BAD_TOOL_LINK) + find_matching_texts(contents, @BAD_TOOL_LINK2) + find_matching_texts(contents, @BAD_TOOL_LINK) + \ + find_matching_texts(contents, @BAD_TOOL_LINK2) .map do |idx, _text, selected| - ReviewDogEmitter.error( - path: @path, - idx: idx, - match_start: selected.begin(0), - match_end: selected.end(0) + 1, - replacement: "{% tool #{selected[1]}(#{selected[2]}) %}", - message: 'You have used the full tool URL to a specific server, here we only need the tool ID portion.', - code: 'GTN:009' - ) - end + ReviewDogEmitter.error( + path: @path, + idx: idx, + match_start: selected.begin(0), + match_end: selected.end(0) + 1, + replacement: "{% tool #{selected[1]}(#{selected[2]}) %}", + message: 'You have used the full tool URL to a specific server, here we only need the tool ID portion.', + code: 'GTN:009' + ) + end end def self.snippets_too_close_together(contents)