Skip to content

Commit b918743

Browse files
committed
Add Ameba static code analysis tool to dev shards
1 parent 32ae38b commit b918743

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

.ameba.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# Lint
3+
#
4+
5+
# Exclude assigns for ECR files
6+
Lint/UselessAssign:
7+
Excluded:
8+
- src/invidious.cr
9+
- src/invidious/helpers/errors.cr
10+
- src/invidious/routes/**/*.cr
11+
12+
# Ignore false negative (if !db.query_one?...)
13+
Lint/UnreachableCode:
14+
Excluded:
15+
- src/invidious/database/base.cr
16+
17+
# Ignore shadowed variable `key` (it works for now, and that's
18+
# a sensitive part of the code)
19+
Lint/ShadowingOuterLocalVar:
20+
Excluded:
21+
- src/invidious/helpers/tokens.cr
22+
23+
24+
#
25+
# Style
26+
#
27+
28+
Style/RedundantBegin:
29+
Enabled: false
30+
31+
Style/RedundantReturn:
32+
Enabled: false
33+
34+
35+
#
36+
# Metrics
37+
#
38+
39+
# Ignore function complexity (number of if/else & case/when branches)
40+
# For some functions that can hardly be simplified for now
41+
Metrics/CyclomaticComplexity:
42+
Excluded:
43+
# get_about_info(ucid, locale) => [17/10]
44+
- src/invidious/channels/about.cr
45+
46+
# fetch_channel_community(ucid, continuation, ...) => [34/10]
47+
- src/invidious/channels/community.cr
48+
49+
# create_notification_stream(env, topics, connection_channel) => [14/10]
50+
- src/invidious/helpers/helpers.cr:84:5
51+
52+
# get_index(plural_form, count) => [25/10]
53+
- src/invidious/helpers/i18next.cr
54+
55+
# call(context) => [18/10]
56+
- src/invidious/helpers/static_file_handler.cr
57+
58+
# show(env) => [38/10]
59+
- src/invidious/routes/embed.cr
60+
61+
# get_video_playback(env) => [45/10]
62+
- src/invidious/routes/video_playback.cr
63+
64+
# handle(env) => [40/10]
65+
- src/invidious/routes/watch.cr
66+
67+
# playlist_ajax(env) => [24/10]
68+
- src/invidious/routes/playlists.cr
69+
70+
# fetch_youtube_comments(id, cursor, ....) => [40/10]
71+
# template_youtube_comments(comments, locale, ...) => [16/10]
72+
# content_to_comment_html(content) => [14/10]
73+
- src/invidious/comments.cr
74+
75+
# to_json(locale, json) => [21/10]
76+
# extract_video_info(video_id, ...) => [44/10]
77+
# process_video_params(query, preferences) => [20/10]
78+
- src/invidious/videos.cr
79+
80+
# produce_search_params(page, sort, ...) => [29/10]
81+
# process_search_query(query, page, ...) => [14/10]
82+
- src/invidious/search.cr
83+
84+
85+
86+
#src/invidious/playlists.cr:327:5
87+
#[C] Metrics/CyclomaticComplexity: Cyclomatic complexity too high [19/10]
88+
# fetch_playlist(plid : String)
89+
90+
#src/invidious/playlists.cr:436:5
91+
#[C] Metrics/CyclomaticComplexity: Cyclomatic complexity too high [11/10]
92+
# extract_playlist_videos(initial_data : Hash(String, JSON::Any))

shard.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ shards:
4848
git: https://github.com/crystal-lang/crystal-sqlite3.git
4949
version: 0.18.0
5050

51+
ameba:
52+
git: https://github.com/crystal-ameba/ameba.git
53+
version: 0.14.3

shard.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ development_dependencies:
3333
spectator:
3434
github: icy-arctic-fox/spectator
3535
version: ~> 0.10.4
36+
ameba:
37+
github: crystal-ameba/ameba
38+
version: ~> 0.14.3
3639

3740
crystal: ">= 1.0.0, < 2.0.0"
3841

0 commit comments

Comments
 (0)