Skip to content

Commit

Permalink
add snippet linting
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed May 18, 2023
1 parent 8d19862 commit 99d87c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions _includes/analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
dsn: "https://[email protected]/10",
release: "galaxy-training-network@{{ site.git_revision }}",
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
tracesSampleRate: 0.01,
sampleRate: 0.1,
tracesSampleRate: 0.1,
// Capture Replay for no sessions by default
replaysSessionSampleRate: 0,
replaysSessionSampleRate: 0.01,
// plus for 1% of sessions with an error
replaysOnErrorSampleRate: 0.01,
// PII OFF
Expand Down
24 changes: 23 additions & 1 deletion bin/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,27 @@ def self.bad_tool_links(contents)
end
end

def self.snippets_too_close_together(contents)
prev_line = -2
res = []
find_matching_texts(contents, /^[> ]*{% snippet/)
.each do |idx, _text, selected|
if idx == prev_line + 1
res.push(ReviewDogEmitter.error(
path: @path,
idx: idx,
match_start: selected.begin(0),
match_end: selected.end(0) + 1,
replacement: nil,
message: 'Snippets too close together',
code: 'GTN:032'
))
end
prev_line = idx
end
res
end

ALLOWED_SHORT_IDS = [
'ChangeCase',
'Convert characters1',
Expand Down Expand Up @@ -683,7 +704,8 @@ def self.fix_md(contents)
*check_bad_tag(contents),
*check_useless_box_prefix(contents),
*check_bad_heading_order(contents),
*check_bolded_heading(contents)
*check_bolded_heading(contents),
*snippets_too_close_together(contents),
]
end

Expand Down

0 comments on commit 99d87c3

Please sign in to comment.