Skip to content

Commit dfcb30c

Browse files
committed
Fix escaping parse error tokens in Elixir 1.6.0
1 parent a78814c commit dfcb30c

File tree

6 files changed

+43
-27
lines changed

6 files changed

+43
-27
lines changed

.credo.exs

+17-9
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,32 @@
1212
#
1313
# Run any exec using `mix credo -C <name>`. If no exec name is given
1414
# "default" is used.
15+
#
1516
name: "default",
1617
#
1718
# These are the files included in the analysis:
1819
files: %{
1920
#
2021
# You can give explicit globs or simply directories.
2122
# In the latter case `**/*.{ex,exs}` will be used.
23+
#
2224
included: ["lib/", "src/", "web/", "apps/"],
2325
excluded: [~r"/_build/", ~r"/deps/"]
2426
},
2527
#
2628
# If you create your own checks, you must specify the source files for
2729
# them here, so they can be loaded by Credo before running the analysis.
28-
requires: [],
2930
#
30-
# Credo automatically checks for updates, like e.g. Hex does.
31-
# You can disable this behaviour below:
32-
check_for_updates: true,
31+
requires: [],
3332
#
3433
# If you want to enforce a style guide and need a more traditional linting
3534
# experience, you can change `strict` to `true` below:
35+
#
3636
strict: false,
3737
#
3838
# If you want to use uncolored output by default, you can change `color`
3939
# to `false` below:
40+
#
4041
color: true,
4142
#
4243
# You can customize the parameters of any check by adding a second element
@@ -54,26 +55,29 @@
5455
{Credo.Check.Consistency.SpaceInParentheses},
5556
{Credo.Check.Consistency.TabsOrSpaces},
5657

57-
# For some checks, like AliasUsage, you can only customize the priority
58+
# You can customize the priority of any check
5859
# Priority values are: `low, normal, high, higher`
60+
#
5961
{Credo.Check.Design.AliasUsage, priority: :low},
6062

61-
# For others you can set parameters
62-
63+
# For some checks, you can also set other parameters
64+
#
6365
# If you don't want the `setup` and `test` macro calls in ExUnit tests
6466
# or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just
6567
# set the `excluded_macros` parameter to `[:schema, :setup, :test]`.
68+
#
6669
{Credo.Check.Design.DuplicatedCode, excluded_macros: []},
6770

6871
# You can also customize the exit_status of each check.
6972
# If you don't want TODO comments to cause `mix credo` to fail, just
7073
# set this value to 0 (zero).
74+
#
7175
{Credo.Check.Design.TagTODO, exit_status: 2},
7276
{Credo.Check.Design.TagFIXME},
7377

7478
{Credo.Check.Readability.FunctionNames},
7579
{Credo.Check.Readability.LargeNumbers},
76-
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 100},
80+
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80},
7781
{Credo.Check.Readability.ModuleAttributeNames},
7882
{Credo.Check.Readability.ModuleDoc, false},
7983
{Credo.Check.Readability.ModuleNames},
@@ -89,10 +93,11 @@
8993
{Credo.Check.Readability.Semicolons},
9094
{Credo.Check.Readability.SpaceAfterCommas},
9195

92-
{Credo.Check.Refactor.DoubleBooleanNegation, false},
96+
{Credo.Check.Refactor.DoubleBooleanNegation},
9397
{Credo.Check.Refactor.CondStatements},
9498
{Credo.Check.Refactor.CyclomaticComplexity},
9599
{Credo.Check.Refactor.FunctionArity},
100+
{Credo.Check.Refactor.LongQuoteBlocks},
96101
{Credo.Check.Refactor.MatchInCondition},
97102
{Credo.Check.Refactor.NegatedConditionsInUnless},
98103
{Credo.Check.Refactor.NegatedConditionsWithElse},
@@ -101,6 +106,7 @@
101106
{Credo.Check.Refactor.UnlessWithElse},
102107

103108
{Credo.Check.Warning.BoolOperationOnSameValues},
109+
{Credo.Check.Warning.ExpensiveEmptyEnumCheck},
104110
{Credo.Check.Warning.IExPry},
105111
{Credo.Check.Warning.IoInspect},
106112
{Credo.Check.Warning.LazyLogging},
@@ -114,6 +120,7 @@
114120
{Credo.Check.Warning.UnusedRegexOperation},
115121
{Credo.Check.Warning.UnusedStringOperation},
116122
{Credo.Check.Warning.UnusedTupleOperation},
123+
{Credo.Check.Warning.RaiseInsideRescue, false},
117124

118125
# Controversial and experimental checks (opt-in, just remove `, false`)
119126
#
@@ -124,6 +131,7 @@
124131
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
125132

126133
# Deprecated checks (these will be deleted after a grace period)
134+
#
127135
{Credo.Check.Readability.Specs, false},
128136
{Credo.Check.Warning.NameRedeclarationByAssignment, false},
129137
{Credo.Check.Warning.NameRedeclarationByCase, false},

.tool-versions

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
erlang 20.2.2
2+
elixir 1.6.0

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ iex> Poison.encode!(%{:foo => "foo1", "foo" => "foo2"}, strict_keys: true)
155155
## Benchmarking
156156

157157
```sh-session
158-
$ MIX_ENV=bench mix run bench/runs.exs
158+
$ MIX_ENV=bench mix run bench/run.exs
159159
```
160160

161161
### Current Benchmarks

lib/poison/parser.ex

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
defmodule Poison.ParseError do
22
@type t :: %__MODULE__{pos: integer, value: String.t}
33

4+
alias Code.Identifier
5+
46
defexception pos: nil, value: nil, rest: nil
57

68
def message(%{value: nil, pos: pos}) do
@@ -17,7 +19,8 @@ defmodule Poison.ParseError do
1719
end
1820

1921
defp escape(token) do
20-
Inspect.BitString.escape(<<token>>, ?\\)
22+
{value, _} = Identifier.escape(<<token>>, ?\\)
23+
value
2124
end
2225
end
2326

mix.exs

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ defmodule Poison.Mixfile do
3838
# Type "mix help deps" for more examples and options
3939
defp deps do
4040
[{:dialyxir, "~> 0.5", only: :dev, runtime: false},
41-
{:ex_doc, "~> 0.16", only: :dev, runtime: false},
42-
{:credo, "~> 0.8.0-rc", only: [:dev, :test], runtime: false},
43-
{:benchee, "~> 0.8", only: :bench},
41+
{:ex_doc, "~> 0.18", only: :dev, runtime: false},
42+
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
43+
{:benchee, "~> 0.11", only: :bench},
4444
{:benchee_json, github: "devinus/benchee_json", branch: "poison-optional", override: true, only: :bench},
45-
{:benchee_html, "~> 0.1", only: :bench},
45+
{:benchee_html, "~> 0.4", only: :bench},
4646
{:exjsx, "~> 4.0", only: :bench},
4747
{:tiny, "~> 1.0", only: :bench},
4848
{:jsone, "~> 1.4", only: :bench},
49-
{:jiffy, "~> 0.14", only: :bench},
49+
{:jiffy, "~> 0.15", only: :bench},
5050
{:json, "~> 1.0", only: :bench}]
5151
end
5252

mix.lock

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
%{"benchee": {:hex, :benchee, "0.8.0", "fe93506d05252ad82d72257f6549aab11664088a1307f26f0ab1acb172b8c35b", [:mix], [{:deep_merge, "~> 0.1", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"},
2-
"benchee_html": {:hex, :benchee_html, "0.3.1", "4f784a567f2999e28d36c13356495f455fad4fb88c66a9c2db60ab2b60d11479", [:mix], [{:benchee, "~> 0.8", [hex: :benchee, repo: "hexpm", optional: false]}, {:benchee_json, ">= 0.3.1", [hex: :benchee_json, repo: "hexpm", optional: false]}], "hexpm"},
3-
"benchee_json": {:git, "https://github.com/devinus/benchee_json.git", "cc574085c02fe166cc9f9fec37c746e0586a3b56", [branch: "poison-optional"]},
1+
%{
2+
"benchee": {:hex, :benchee, "0.11.0", "cf96e328ff5d69838dd89c21a9db22716bfcc6ef772e9d9dddf7ba622102722d", [:mix], [{:deep_merge, "~> 0.1", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"},
3+
"benchee_html": {:hex, :benchee_html, "0.4.0", "9576ef6058e3292ea6bb670d11f84e70484808c355d484fd17c2a749d40bc23e", [:mix], [{:benchee, "~> 0.10", [hex: :benchee, repo: "hexpm", optional: false]}, {:benchee_json, "~> 0.4", [hex: :benchee_json, repo: "hexpm", optional: false]}], "hexpm"},
4+
"benchee_json": {:git, "https://github.com/devinus/benchee_json.git", "70382530019c79146b6b516f006ba951174683e2", [branch: "poison-optional"]},
45
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
5-
"credo": {:hex, :credo, "0.8.0-rc7", "8cd92113a5cb37487102e5551240bdc6e4d93c19bdf7fc902f865ff0b4887256", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
6+
"credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"},
67
"deep_merge": {:hex, :deep_merge, "0.1.1", "c27866a7524a337b6a039eeb8dd4f17d458fd40fbbcb8c54661b71a22fffe846", [:mix], [], "hexpm"},
7-
"dialyxir": {:hex, :dialyxir, "0.5.0", "5bc543f9c28ecd51b99cc1a685a3c2a1a93216990347f259406a910cf048d1d7", [:mix], [], "hexpm"},
8-
"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"},
9-
"ex_doc": {:hex, :ex_doc, "0.16.1", "b4b8a23602b4ce0e9a5a960a81260d1f7b29635b9652c67e95b0c2f7ccee5e81", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
8+
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
9+
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
10+
"ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
1011
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},
11-
"jiffy": {:hex, :jiffy, "0.14.11", "919a87d491c5a6b5e3bbc27fafedc3a0761ca0b4c405394f121f582fd4e3f0e5", [:rebar3], [], "hexpm"},
12+
"jiffy": {:hex, :jiffy, "0.15.0", "c44b61ea7b5d81b5bbd95ea5922d7c5f915d5bf15500fd1372c1aa10404673a9", [:rebar3], [], "hexpm"},
1213
"json": {:hex, :json, "1.0.2", "fa75ed4f355cd4ab468c25588171f8002a7274d3d5fb376c18822ddfc7c33f1f", [:mix], [], "hexpm"},
13-
"jsone": {:hex, :jsone, "1.4.3", "6d5f802136249e64f9d4997043b13355c6eac314217dc3b19bf3677e351a0641", [:rebar3], [], "hexpm"},
14-
"jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], [], "hexpm"},
15-
"tiny": {:hex, :tiny, "1.0.1", "535ea7e600cb1c6ba17b53029266d9d7ec54ce29bfb05d906c433907acfa01ca", [:mix], [], "hexpm"}}
14+
"jsone": {:hex, :jsone, "1.4.5", "547aefec1c67fe3283f77bac4daf85f3f593002764f768faaa423875a51a2320", [:rebar3], [], "hexpm"},
15+
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"},
16+
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
17+
"tiny": {:hex, :tiny, "1.0.1", "535ea7e600cb1c6ba17b53029266d9d7ec54ce29bfb05d906c433907acfa01ca", [:mix], [], "hexpm"},
18+
}

0 commit comments

Comments
 (0)