Skip to content

Commit

Permalink
add zenodo api url linting
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Oct 16, 2023
1 parent 46b04fb commit 2882163
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bin/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,21 @@ def self.check_bolded_heading(contents)
end
end

def self.zenodo_api(contents)
find_matching_texts(contents, /(zenodo\.org\/api\/files\/)/)
.map do |idx, _text, selected|
ReviewDogEmitter.error(
path: @path,
idx: idx,
match_start: selected.begin(1),
match_end: selected.end(1) + 1,
replacement: nil,
message: 'The Zenodo.org/api URLs are not stable, you must use a URL of the format zenodo.org/record/..., apologies we cannot fix automatically.',
code: 'GTN:032'
)
end
end

def self.fix_md(contents)
[
*fix_notoc(contents),
Expand All @@ -707,7 +722,8 @@ def self.fix_md(contents)
*check_useless_box_prefix(contents),
*check_bad_heading_order(contents),
*check_bolded_heading(contents),
*snippets_too_close_together(contents)
*snippets_too_close_together(contents),
*zenodo_api(contents),
]
end

Expand Down

0 comments on commit 2882163

Please sign in to comment.