Skip to content

Commit 03c8dfe

Browse files
authored
Merge pull request #124 from djgoku/fix/extra-parens
Fix/extra parens
2 parents d11a2a0 + d81b7b7 commit 03c8dfe

File tree

6 files changed

+73
-61
lines changed

6 files changed

+73
-61
lines changed

.github/workflows/gen_elixir.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
elixir: ["1.13.4"]
19-
erlang: ["25.0.4"]
18+
elixir: ["1.18.3"]
19+
erlang: ["26"]
2020

2121
steps:
2222
- uses: actions/checkout@v2
@@ -51,4 +51,4 @@ jobs:
5151
run: |
5252
mix deps.get
5353
mix test
54-
working-directory: aws-beam/aws-elixir
54+
working-directory: aws-beam/aws-elixir

.github/workflows/gen_erlang.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ jobs:
1212
strategy:
1313
matrix:
1414
platform: [ubuntu-latest]
15-
elixir: ["1.13.4"]
16-
erlang: ["25.0.4"]
17-
rebar3: ['3.20.0']
15+
elixir: ["1.18.3"]
16+
erlang: ["26"]
17+
rebar3: ["3.25.0"]
1818
runs-on: ${{ matrix.platform }}
1919
services:
2020
ddb:
2121
image: amazon/dynamodb-local:1.21.0
2222
ports:
2323
- 8000:8000
2424
s3mock:
25-
image: adobe/s3mock:2.11.0
25+
image: adobe/s3mock:4.6.0
2626
ports:
2727
- 9090:9090
2828
steps:

lib/aws_codegen/types.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,24 @@ defmodule AWS.CodeGen.Types do
103103
%Shape{type: "structure"} ->
104104
type =
105105
"#{AWS.CodeGen.Name.to_snake_case(String.replace(shape_name, ~r/com\.amazonaws\.[^#]+#/, ""))}"
106+
|> AWS.CodeGen.Util.maybe_add_parens()
106107

107108
if reserved_type(type) do
108-
"#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}()"
109+
"#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}"
109110
else
110-
"#{type}()"
111+
"#{type}"
111112
end
112113

113114
%Shape{type: "list", member: member} ->
114-
type = "#{shape_to_type(context, member["target"], module_name, all_shapes)}"
115+
# this change alone gets us down to 1595
116+
type =
117+
"#{shape_to_type(context, member["target"], module_name, all_shapes)}"
118+
|> AWS.CodeGen.Util.maybe_add_parens()
115119

116120
if reserved_type(type) do
117-
"list(#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type}())"
121+
"list(#{String.downcase(String.replace(context.module_name, ["aws_", "AWS."], ""))}_#{type})"
118122
else
119-
"list(#{type}())"
123+
"list(#{type})"
120124
end
121125

122126
nil ->

lib/aws_codegen/util.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,12 @@ defmodule AWS.CodeGen.Util do
6262
|> Enum.reverse()
6363
end
6464
end
65+
66+
def maybe_add_parens(string) do
67+
if String.ends_with?(string, "()") do
68+
string
69+
else
70+
string <> "()"
71+
end
72+
end
6573
end

test/aws_codegen_test.exs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ defmodule AWS.CodeGenTest do
171171
172172
put_audit_events_request() :: %{
173173
optional(\"externalId\") => String.t(),
174-
required(\"auditEvents\") => list(audit_event()()),
174+
required(\"auditEvents\") => list(audit_event()),
175175
required(\"channelArn\") => String.t()
176176
}
177177
@@ -183,8 +183,8 @@ defmodule AWS.CodeGenTest do
183183
## Example:
184184
185185
put_audit_events_response() :: %{
186-
required(\"failed\") => list(result_error_entry()()),
187-
required(\"successful\") => list(audit_event_result_entry()())
186+
required(\"failed\") => list(result_error_entry()),
187+
required(\"successful\") => list(audit_event_result_entry())
188188
}
189189
190190
\"\"\"
@@ -409,7 +409,7 @@ defmodule AWS.CodeGenTest do
409409
410410
put_audit_events_request() :: %{
411411
optional(\"externalId\") => String.t(),
412-
required(\"auditEvents\") => list(audit_event()()),
412+
required(\"auditEvents\") => list(audit_event()),
413413
required(\"channelArn\") => String.t()
414414
}
415415
@@ -421,8 +421,8 @@ defmodule AWS.CodeGenTest do
421421
## Example:
422422
423423
put_audit_events_response() :: %{
424-
required(\"failed\") => list(result_error_entry()()),
425-
required(\"successful\") => list(audit_event_result_entry()())
424+
required(\"failed\") => list(result_error_entry()),
425+
required(\"successful\") => list(audit_event_result_entry())
426426
}
427427
428428
\"\"\"
@@ -653,7 +653,7 @@ defmodule AWS.CodeGenTest do
653653
654654
put_audit_events_request() :: %{
655655
optional(\"externalId\") => String.t(),
656-
required(\"auditEvents\") => list(audit_event()()),
656+
required(\"auditEvents\") => list(audit_event()),
657657
required(\"channelArn\") => String.t()
658658
}
659659
@@ -665,8 +665,8 @@ defmodule AWS.CodeGenTest do
665665
## Example:
666666
667667
put_audit_events_response() :: %{
668-
required(\"failed\") => list(result_error_entry()()),
669-
required(\"successful\") => list(audit_event_result_entry()())
668+
required(\"failed\") => list(result_error_entry()),
669+
required(\"successful\") => list(audit_event_result_entry())
670670
}
671671
672672
\"\"\"

0 commit comments

Comments
 (0)