Skip to content

Commit

Permalink
Address a bug in erlang.el formatter (2600hz#5431)
Browse files Browse the repository at this point in the history
* cleanup fold

* fixed formatting issues

fixed a bug in erlang.el (locally) that was causing formatting to die
early on a file. Re-ran formatting across the project to fix up these
files.

Also found that the app-specific fmt was differing from the root fmt
target.

* include fmt targets in same way for root make and per-app

* add clean-fmt target to clean

* include test modules in fmt

* maintain patched erlang.el for now

erlang.el pulled from melpa:erlang-20181011.1236

* more fold cleanup

* fix up specs

* log dry run based on boolean

* oh yeah dollar signs still a pain

* more dollar signs

* even more dollar signs

* fix the funs in tuples issue
  • Loading branch information
jamesaimonetti authored and harenson committed Jan 18, 2019
1 parent 7e1dc7d commit c770c35
Show file tree
Hide file tree
Showing 27 changed files with 6,339 additions and 226 deletions.
20 changes: 2 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ROOT = $(shell cd "$(dirname '.')" && pwd -P)
RELX = $(ROOT)/deps/relx
ELVIS = $(ROOT)/deps/elvis
FMT = $(ROOT)/make/erlang-formatter/fmt.sh
TAGS = $(ROOT)/TAGS
ERLANG_MK_COMMIT = d30dda39b08e6ed9e12b44533889eaf90aba86de

Expand Down Expand Up @@ -29,7 +28,6 @@ JOBS ?= 1
docs \
elvis \
fixture_shell \
fmt clean-fmt \
fs-headers \
install \
sdks \
Expand All @@ -46,7 +44,7 @@ clean: clean-kazoo
$(if $(wildcard *crash.dump), rm *crash.dump)
$(if $(wildcard scripts/log/*), rm -rf scripts/log/*)
$(if $(wildcard rel/dev-vm.args), rm rel/dev-vm.args)
$(if $(wildcard $(FMT)), rm -r $(dir $(FMT)))

clean-kazoo: clean-core clean-apps
clean-core:
@$(MAKE) -j$(JOBS) -C core/ clean
Expand Down Expand Up @@ -249,21 +247,6 @@ diff: dialyze-it
bump-copyright:
@$(ROOT)/scripts/bump-copyright-year.sh $(shell find applications core -iname '*.erl' -or -iname '*.hrl')

FMT_SHA = 237604a566879bda46d55d9e74e3e66daf1b557a
$(FMT):
wget -qO - 'https://codeload.github.com/fenollp/erlang-formatter/tar.gz/$(FMT_SHA)' | tar -vxz -C $(ROOT)/make/
mv $(ROOT)/make/erlang-formatter-$(FMT_SHA) $(ROOT)/make/erlang-formatter

fmt-all: $(FMT)
@$(FMT) $(shell find core applications scripts -name "*.erl" -or -name "*.hrl" -or -name "*.escript")

fmt: TO_FMT ?= $(shell git --no-pager diff --name-only HEAD $(BASE_BRANCH) -- "*.erl" "*.hrl" "*.escript")
fmt: $(FMT)
@$(if $(TO_FMT), @$(FMT) $(TO_FMT))

clean-fmt:
@$(if $(FMT), rm -rf $(shell dirname $(FMT)))

app_applications:
ERL_LIBS=deps:core:applications $(ROOT)/scripts/apps_of_app.escript -a $(shell find applications -name *.app.src)

Expand Down Expand Up @@ -324,5 +307,6 @@ validate-schemas:

include make/splchk.mk
include make/ci.mk
include make/fmt.mk

circle: ci
94 changes: 47 additions & 47 deletions applications/callflow/src/module/cf_audio_macro.erl
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,30 @@ schema_test_() ->
,\"duration_off\":200
}
]
}">>,
}">>,

build_tests(Data).

another_schema_test_() ->
Data = <<"{
\"macros\": [
{
\"macro\": \"play\",
\"macro\": \"play\",
\"id\": \"http://server.com/you-pressed-1.wav\",
\"endless_playback\": false
},
{
\"macro\": \"play\",
{
\"macro\": \"play\",
\"id\": \"http://server.com/you-pressed-2.wav\",
\"endless_playback\": false
},
{
\"macro\": \"play\",
{
\"macro\": \"play\",
\"id\": \"http://server.com/something.mp3\",
\"endless_playback\": false
}
],
\"terminators\": [
],
\"terminators\": [
\"1\",
\"2\",
\"3\",
Expand All @@ -197,14 +197,14 @@ another_schema_test_() ->
\"0\",
\"#\"
]
}">>,
}">>,
build_tests(Data).

yas_test_() ->
Data = <<"{
\"macros\": [
{
\"macro\": \"tts\",
\"macro\": \"tts\",
\"text\": \"one to 4\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -222,9 +222,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -242,9 +242,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"one to 4\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -262,9 +262,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -282,9 +282,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"one to 4\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -302,9 +302,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -322,9 +322,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"one to 4\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -342,9 +342,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -362,9 +362,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"one to 4\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -382,9 +382,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -402,9 +402,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"one to 4\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -422,9 +422,9 @@ yas_test_() ->
\"0\",
\"#\"
]
},
{
\"macro\": \"tts\",
},
{
\"macro\": \"tts\",
\"text\": \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28\",
\"language\": \"en-US\",
\"voice\": \"male\",
Expand All @@ -442,9 +442,9 @@ yas_test_() ->
\"0\",
\"#\"
]
}
]
}">>,
}
]
}">>,
build_tests(Data).

build_tests(Data) ->
Expand All @@ -453,7 +453,7 @@ build_tests(Data) ->
end
,[]
,[fun validate/1
,fun build_macro_command/1
,fun build_macro_command/1
]
).

Expand Down
Loading

0 comments on commit c770c35

Please sign in to comment.