Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Jul 13, 2023
1 parent 96cae5a commit 2c29976
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
8 changes: 6 additions & 2 deletions _plugins/author-page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion _plugins/jekyll-duration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
25 changes: 13 additions & 12 deletions bin/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2c29976

Please sign in to comment.