Skip to content

Commit 81bb2bd

Browse files
kahgohjiegillet
andauthored
Add analyzer for gotta-snatch-em-all (#451)
* Add analyzer for gotta-snatch-em-all * Fix space alignment & formatting * Add tests for gotta snatch em all analyzer * Fix wording & spelling mistakes Co-authored-by: Jie <jie.gillet@gmail.com> --------- Co-authored-by: Jie <jie.gillet@gmail.com>
1 parent 9daa2db commit 81bb2bd

File tree

4 files changed

+562
-0
lines changed

4 files changed

+562
-0
lines changed

config/config.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ config :elixir_analyzer,
6363
"german-sysadmin" => %{
6464
analyzer_module: ElixirAnalyzer.TestSuite.GermanSysadmin
6565
},
66+
"gotta-snatch-em-all" => %{
67+
analyzer_module: ElixirAnalyzer.TestSuite.GottaSnatchEmAll
68+
},
6669
"high-school-sweetheart" => %{
6770
analyzer_module: ElixirAnalyzer.TestSuite.HighSchoolSweetheart
6871
},

lib/elixir_analyzer/constants.ex

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,34 @@ defmodule ElixirAnalyzer.Constants do
100100
german_sysadmin_no_string: "elixir.german-sysadmin.no_string",
101101
german_sysadmin_use_case: "elixir.german-sysadmin.use_case",
102102

103+
# Gotta Snatch Em All Comments
104+
gotta_snatch_em_all_add_card_use_mapset_member_and_put:
105+
"elixir.gotta-snatch-em-all.add_card_use_mapset_member_and_put",
106+
gotta_snatch_em_all_trade_card_use_mapset_member_put_and_delete:
107+
"elixir.gotta-snatch-em-all.trade_card_use_mapset_member_put_and_delete",
108+
gotta_snatch_em_all_remove_duplicates_use_mapset_new:
109+
"elixir.gotta-snatch-em-all.remove_duplicates_use_mapset_new",
110+
gotta_snatch_em_all_remove_duplicates_use_enum_sort:
111+
"elixir.gotta-snatch-em-all.remove_duplicates_use_enum_sort",
112+
gotta_snatch_em_all_remove_duplicates_do_not_use_enum_uniq:
113+
"elixir.gotta-snatch-em-all.remove_duplicates_do_not_use_enum_uniq",
114+
gotta_snatch_em_all_extra_cards_use_mapset_difference_and_size:
115+
"elixir.gotta-snatch-em-all.extra_cards_use_mapset_difference_and_size",
116+
gotta_snatch_em_all_boring_cards_use_mapset_intersection:
117+
"elixir.gotta-snatch-em-all.boring_cards_use_mapset_intersection",
118+
gotta_snatch_em_all_boring_cards_use_enum_sort:
119+
"elixir.gotta-snatch-em-all.boring_cards_use_enum_sort",
120+
gotta_snatch_em_all_boring_cards_use_enum_reduce:
121+
"elixir.gotta-snatch-em-all.boring_cards_use_enum_reduce",
122+
gotta_snatch_em_all_total_cards_use_mapset_union_and_size:
123+
"elixir.gotta-snatch-em-all.total_cards_use_mapset_union_and_size",
124+
gotta_snatch_em_all_total_cards_use_enum_reduce:
125+
"elixir.gotta-snatch-em-all.total_cards_use_enum_reduce",
126+
gotta_snatch_em_all_split_shiny_cards_use_enum_sort:
127+
"elixir.gotta-snatch-em-all.shiny_cards_use_enum_sort",
128+
gotta_snatch_em_all_split_shiny_cards_use_string_starts_with:
129+
"elixir.gotta-snatch-em-all.shiny_cards_use_string_starts_with",
130+
103131
# Guessing Game Comments
104132
guessing_game_use_default_argument: "elixir.guessing-game.use_default_argument",
105133
guessing_game_use_multiple_clause_functions:
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
defmodule ElixirAnalyzer.TestSuite.GottaSnatchEmAll do
2+
@moduledoc """
3+
This is an exercise analyzer extension module for the concept exercise Gotta Snatch Em All
4+
"""
5+
use ElixirAnalyzer.ExerciseTest
6+
alias ElixirAnalyzer.Constants
7+
8+
assert_call "add_card uses MapSet.member?" do
9+
type :essential
10+
calling_fn module: GottaSnatchEmAll, name: :add_card
11+
called_fn module: MapSet, name: :member?
12+
comment Constants.gotta_snatch_em_all_add_card_use_mapset_member_and_put()
13+
end
14+
15+
assert_call "add_card uses MapSet.put" do
16+
type :essential
17+
calling_fn module: GottaSnatchEmAll, name: :add_card
18+
called_fn module: MapSet, name: :put
19+
comment Constants.gotta_snatch_em_all_add_card_use_mapset_member_and_put()
20+
suppress_if "add_card uses MapSet.member?", :fail
21+
end
22+
23+
assert_call "trade_card uses MapSet.member?" do
24+
type :essential
25+
calling_fn module: GottaSnatchEmAll, name: :trade_card
26+
called_fn module: MapSet, name: :member?
27+
comment Constants.gotta_snatch_em_all_trade_card_use_mapset_member_put_and_delete()
28+
end
29+
30+
assert_call "trade_card uses MapSet.put" do
31+
type :essential
32+
calling_fn module: GottaSnatchEmAll, name: :trade_card
33+
called_fn module: MapSet, name: :put
34+
comment Constants.gotta_snatch_em_all_trade_card_use_mapset_member_put_and_delete()
35+
suppress_if "trade_card uses MapSet.member?", :fail
36+
end
37+
38+
assert_call "trade_card uses MapSet.delete" do
39+
type :essential
40+
calling_fn module: GottaSnatchEmAll, name: :trade_card
41+
called_fn module: MapSet, name: :delete
42+
comment Constants.gotta_snatch_em_all_trade_card_use_mapset_member_put_and_delete()
43+
suppress_if "trade_card uses MapSet.member?", :fail
44+
suppress_if "trade_card uses MapSet.put", :fail
45+
end
46+
47+
assert_call "remove_duplicates uses MapSet.new" do
48+
type :essential
49+
calling_fn module: GottaSnatchEmAll, name: :remove_duplicates
50+
called_fn module: MapSet, name: :new
51+
comment Constants.gotta_snatch_em_all_remove_duplicates_use_mapset_new()
52+
end
53+
54+
assert_call "remove_duplicates uses Enum.sort" do
55+
type :essential
56+
calling_fn module: GottaSnatchEmAll, name: :remove_duplicates
57+
called_fn module: Enum, name: :sort
58+
comment Constants.gotta_snatch_em_all_remove_duplicates_use_enum_sort()
59+
end
60+
61+
assert_no_call "remove_duplicates does not use Enum.uniq" do
62+
type :essential
63+
calling_fn module: GottaSnatchEmAll, name: :remove_duplicates
64+
called_fn module: Enum, name: :uniq
65+
comment Constants.gotta_snatch_em_all_remove_duplicates_do_not_use_enum_uniq()
66+
end
67+
68+
assert_call "extra_cards uses MapSet.difference" do
69+
type :essential
70+
calling_fn module: GottaSnatchEmAll, name: :extra_cards
71+
called_fn module: MapSet, name: :difference
72+
comment Constants.gotta_snatch_em_all_extra_cards_use_mapset_difference_and_size()
73+
end
74+
75+
assert_call "extra_cards uses MapSet.size" do
76+
type :essential
77+
calling_fn module: GottaSnatchEmAll, name: :extra_cards
78+
called_fn module: MapSet, name: :size
79+
comment Constants.gotta_snatch_em_all_extra_cards_use_mapset_difference_and_size()
80+
suppress_if "extra_cards uses MapSet.difference", :fail
81+
end
82+
83+
assert_call "boring_cards uses MapSet.intersection" do
84+
type :essential
85+
calling_fn module: GottaSnatchEmAll, name: :boring_cards
86+
called_fn module: MapSet, name: :intersection
87+
comment Constants.gotta_snatch_em_all_boring_cards_use_mapset_intersection()
88+
end
89+
90+
assert_call "boring_cards uses Enum.sort" do
91+
type :essential
92+
calling_fn module: GottaSnatchEmAll, name: :boring_cards
93+
called_fn module: Enum, name: :sort
94+
comment Constants.gotta_snatch_em_all_boring_cards_use_enum_sort()
95+
end
96+
97+
assert_call "boring_cards uses Enum.reduce" do
98+
type :actionable
99+
calling_fn module: GottaSnatchEmAll, name: :boring_cards
100+
called_fn module: Enum, name: :reduce
101+
comment Constants.gotta_snatch_em_all_boring_cards_use_enum_reduce()
102+
end
103+
104+
assert_call "total_cards uses MapSet.union" do
105+
type :essential
106+
calling_fn module: GottaSnatchEmAll, name: :total_cards
107+
called_fn module: MapSet, name: :union
108+
comment Constants.gotta_snatch_em_all_total_cards_use_mapset_union_and_size()
109+
end
110+
111+
assert_call "total_cards uses MapSet.size" do
112+
type :essential
113+
calling_fn module: GottaSnatchEmAll, name: :total_cards
114+
called_fn module: MapSet, name: :size
115+
comment Constants.gotta_snatch_em_all_total_cards_use_mapset_union_and_size()
116+
suppress_if "total_cards uses MapSet.union", :fail
117+
end
118+
119+
assert_call "total_cards uses Enum.reduce" do
120+
type :actionable
121+
calling_fn module: GottaSnatchEmAll, name: :total_cards
122+
called_fn module: Enum, name: :reduce
123+
comment Constants.gotta_snatch_em_all_total_cards_use_enum_reduce()
124+
end
125+
126+
assert_call "split_shiny_cards uses Enum.sort" do
127+
type :essential
128+
calling_fn module: GottaSnatchEmAll, name: :split_shiny_cards
129+
called_fn module: Enum, name: :sort
130+
comment Constants.gotta_snatch_em_all_split_shiny_cards_use_enum_sort()
131+
end
132+
133+
assert_call "split_shiny_cards uses String.starts_with" do
134+
type :actionable
135+
calling_fn module: GottaSnatchEmAll, name: :split_shiny_cards
136+
called_fn module: String, name: :starts_with?
137+
comment Constants.gotta_snatch_em_all_split_shiny_cards_use_string_starts_with()
138+
end
139+
end

0 commit comments

Comments
 (0)