You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ji...@apache.org on 2024/12/30 17:56:15 UTC
(couchdb) branch fix-elixir-compile-warnings created (now 54a2baee1)
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a change to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at 54a2baee1 Fix warnings about comparison between distinct types
This branch includes the following new commits:
new 27ab00075 Add `:leex` and `:yecc` to mix.exs
new d9d83fe9d Fix warnings about quotes
new 39648636d Prefix unused variables with an underscore
new 6636e5bb6 Fix warnings about undefined functions
new c73b5bea2 Remove warnings about `test_chttpd_auth_lockout_warning`
new f5f4e8212 Fix warnings about operator `===` has no effect
new 54a2baee1 Fix warnings about comparison between distinct types
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(couchdb) 02/07: Fix warnings about quotes
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit d9d83fe9d9057dc7f8c7f653ca90344d069ed412
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Fri Aug 16 16:13:18 2024 -0500
Fix warnings about quotes
```
warning: single-quoted strings represent charlists. Use ~c"" if you indeed want a charlist or use "" instead.
You may run "mix format --migrate" to fix this warning automatically.
│
43 │ addr = :config.get('couch_httpd', 'bind_address', '127.0.0.1')
│ ~
│
└─ test/elixir/lib/step/start.ex:43:24
warning: found quoted keyword "_id" but the quotes are not required. Note that keywords are always atoms, even when quoted. Similar to atoms, keywords made exclusively of ASCII letters, numbers, and underscores and not beginning with a number do not require quotes
│
91 │ docs ++ [%{"_id": "#{doc2._id}", "_rev": att_rev2}]
│ ~
│
└─ test/elixir/test/compact_test.exs:91:16
```
---
test/elixir/lib/step/start.ex | 4 ++--
test/elixir/lib/step/user.ex | 4 ++--
test/elixir/test/attachments_test.exs | 2 +-
test/elixir/test/compact_test.exs | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/elixir/lib/step/start.ex b/test/elixir/lib/step/start.ex
index 1be1cb1dc..b86b14a4f 100644
--- a/test/elixir/lib/step/start.ex
+++ b/test/elixir/lib/step/start.ex
@@ -40,13 +40,13 @@ defmodule Couch.Test.Setup.Step.Start do
test_config = setup |> Setup.get(:test_config) |> Step.Config.get()
protocol = test_config[:backdoor][:protocol] || "http"
test_ctx = :test_util.start_couch(extra_apps)
- addr = :config.get('couch_httpd', 'bind_address', '127.0.0.1')
+ addr = :config.get("couch_httpd", "bind_address", "127.0.0.1")
port = :mochiweb_socket_server.get(:couch_httpd, :port)
backdoor_url = "#{protocol}://#{addr}:#{port}"
clustered_url =
if :chttpd in extra_apps do
protocol = test_config[:clustered][:protocol] || "http"
- addr = :config.get('chttpd', 'bind_address', '127.0.0.1')
+ addr = :config.get("chttpd", "bind_address", "127.0.0.1")
port = :mochiweb_socket_server.get(:chttpd, :port)
"#{protocol}://#{addr}:#{port}"
else
diff --git a/test/elixir/lib/step/user.ex b/test/elixir/lib/step/user.ex
index 49ef0feae..15c5116a1 100644
--- a/test/elixir/lib/step/user.ex
+++ b/test/elixir/lib/step/user.ex
@@ -33,7 +33,7 @@ defmodule Couch.Test.Setup.Step.User do
def setup(_setup, %__MODULE__{roles: roles} = step) do
users_db = IO.chardata_to_string(
- :config.get('chttpd_auth', 'authentication_db', '_users'))
+ :config.get("chttpd_auth", "authentication_db", "_users"))
if not Utils.db_exists?(users_db) do
on_exit fn ->
:fabric.delete_db(users_db, [@admin])
@@ -46,7 +46,7 @@ defmodule Couch.Test.Setup.Step.User do
name = Utils.random_name("admin")
pass = Utils.random_password()
:config.set(
- 'admins', String.to_charlist(name), String.to_charlist(pass), false)
+ "admins", String.to_charlist(name), String.to_charlist(pass), false)
%{step |
name: name,
password: pass,
diff --git a/test/elixir/test/attachments_test.exs b/test/elixir/test/attachments_test.exs
index 13a5c84f9..2d3251b19 100644
--- a/test/elixir/test/attachments_test.exs
+++ b/test/elixir/test/attachments_test.exs
@@ -131,7 +131,7 @@ defmodule AttachmentsTest do
assert resp.status_code in [201, 202]
rev = resp.body["rev"]
- resp = Couch.delete("/#{db_name}/bin_doc/foo.txt", body: 'some payload', query: %{w: 3, rev: rev}, ibrowse: [{:max_sessions, 1}, {:max_pipeline_size, 1}])
+ resp = Couch.delete("/#{db_name}/bin_doc/foo.txt", body: "some payload", query: %{w: 3, rev: rev}, ibrowse: [{:max_sessions, 1}, {:max_pipeline_size, 1}])
assert resp.status_code == 200
resp = Couch.get("/", timeout: 1000, ibrowse: [{:max_sessions, 1}, {:max_pipeline_size, 1}])
diff --git a/test/elixir/test/compact_test.exs b/test/elixir/test/compact_test.exs
index 6edd77c01..881f57035 100644
--- a/test/elixir/test/compact_test.exs
+++ b/test/elixir/test/compact_test.exs
@@ -88,7 +88,7 @@ defmodule CompactTest do
assert resp.status_code in [201, 202]
att_rev2 = resp.body["rev"]
- docs ++ [%{"_id": "#{doc2._id}", "_rev": att_rev2}]
+ docs ++ [%{_id: "#{doc2._id}", _rev: att_rev2}]
end
defp delete(db, docs) do
(couchdb) 05/07: Remove warnings about `test_chttpd_auth_lockout_warning`
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit c73b5bea2663415975742a62c07cbda38e9310d6
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Sun Dec 29 22:44:46 2024 -0600
Remove warnings about `test_chttpd_auth_lockout_warning`
```
warning: function test_chttpd_auth_lockout_warning/0 is unused
│
48 │ defp test_chttpd_auth_lockout_warning do
│ ~
│
└─ test/elixir/test/auth_lockout_test.exs:48:8: AuthLockoutTest (module)
```
---
test/elixir/test/auth_lockout_test.exs | 41 ++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/test/elixir/test/auth_lockout_test.exs b/test/elixir/test/auth_lockout_test.exs
index b039c86eb..668eb7104 100644
--- a/test/elixir/test/auth_lockout_test.exs
+++ b/test/elixir/test/auth_lockout_test.exs
@@ -20,10 +20,19 @@ defmodule AuthLockoutTest do
}
]
- run_on_modified_server(
- server_config,
- fn -> test_chttpd_auth_lockout_enforcement() end
- )
+ run_on_modified_server(server_config, &test_chttpd_auth_lockout_enforcement/0)
+ end
+
+ test "do not lockout after multiple failed authentications", _context do
+ server_config = [
+ %{
+ :section => "chttpd_auth_lockout",
+ :key => "mode",
+ :value => "warn"
+ }
+ ]
+
+ run_on_modified_server(server_config, &test_chttpd_auth_lockout_warning/0)
end
defp test_chttpd_auth_lockout_enforcement do
@@ -31,34 +40,32 @@ defmodule AuthLockoutTest do
for _n <- 1..5 do
resp = Couch.get("/_all_dbs",
no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
- )
+ headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
+ )
+
assert resp.status_code == 401
end
# locked out?
resp = Couch.get("/_all_dbs",
no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
+ headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
)
+
assert resp.status_code == 403
- assert resp.body["reason"] == "Account is temporarily locked due to multiple authentication failures"
+ assert resp.body["reason"] ==
+ "Account is temporarily locked due to multiple authentication failures"
end
defp test_chttpd_auth_lockout_warning do
# exceed the lockout threshold
- for _n <- 1..5 do
+ for _n <- 1..6 do
resp = Couch.get("/_all_dbs",
no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
- )
+ headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
+ )
+
assert resp.status_code == 401
end
-
- # warning?
- _resp = Couch.get("/_all_dbs",
- no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
- )
end
end
(couchdb) 04/07: Fix warnings about undefined functions
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 6636e5bb62c1f9c2ec4084e76b83643e120658d9
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Mon Dec 30 11:16:42 2024 -0600
Fix warnings about undefined functions
```
warning: :fabric.get_db_info/1 is undefined (module :fabric is not available or is yet to be defined)
│
26 │ :fabric.get_db_info(db_name)
│ ~
│
└─ test/elixir/lib/utils.ex:26:15: Couch.Test.Utils.db_exists?/1
```
---
mix.exs | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/mix.exs b/mix.exs
index 5c77f1bbd..200d37dc2 100644
--- a/mix.exs
+++ b/mix.exs
@@ -85,17 +85,22 @@ defmodule CouchDBTest.Mixfile do
# Run "mix help deps" to learn about dependencies.
defp deps() do
- deps_list = [
+ deps1 = [
{:junit_formatter, "~> 3.0", only: [:dev, :test, :integration]},
{:httpotion, ">= 3.1.3", only: [:dev, :test, :integration], runtime: false},
{:excoveralls, "~> 0.12", only: :test},
- {:b64url, path: path("b64url")},
- {:jiffy, path: path("jiffy")},
- {:jwtf, path: path("jwtf")},
- {:ibrowse, path: path("ibrowse"), override: true},
- {:credo, "~> 1.7.7", only: [:dev, :test, :integration], runtime: false}
+ {:credo, "~> 1.7.7", only: [:dev, :test, :integration], runtime: false},
+ {:ibrowse, path: path("ibrowse"), override: true}
]
+ extra_deps = [:b64url, :jiffy, :jwtf, :meck, :mochiweb]
+ couch_deps = [:config, :couch, :couch_mrview, :fabric, :mem3]
+
+ deps2 = Enum.map(extra_deps, &{&1, path: path(&1)})
+ deps3 = Enum.map(couch_deps, &{&1, path: link_ebin(&1), compile: false})
+
+ deps_list = deps1 ++ deps2 ++ deps3
+
# Some deps may be missing during source check
# Besides we don't want to spend time checking them anyway
List.foldl([:b64url, :jiffy, :jwtf, :ibrowse], deps_list, fn dep, acc ->
@@ -107,9 +112,14 @@ defmodule CouchDBTest.Mixfile do
end)
end
- defp path(app) do
- lib_dir = Path.expand("src", __DIR__)
- Path.expand(app, lib_dir)
+ defp path(app), do: Path.expand("src/#{app}", __DIR__)
+
+ defp link_ebin(app) do
+ app_ebin = Path.expand("src/#{app}/ebin", __DIR__)
+ build_ebin = "_build/#{Mix.env()}/lib/#{app}/ebin"
+ File.mkdir_p!(Path.dirname(build_ebin))
+ unless File.exists?(build_ebin), do: System.cmd("ln", ["-s", app_ebin, build_ebin])
+ path(app)
end
def get_test_paths(:test) do
(couchdb) 07/07: Fix warnings about comparison between distinct types
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 54a2baee1e3994b94d4dae5886f9b9dcbb397b15
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Mon Dec 30 11:51:20 2024 -0600
Fix warnings about comparison between distinct types
```
warning: comparison between distinct types found:
N >= 10
given types:
N >= integer()
While Elixir can compare across all types, you are comparing across types which are always disjoint, and the result is either always true or always false
typing violation found at:
│
1310 │ N when (N >= 10 and N < 15) or is_ddoc ->
│ ~
│
└─ test/elixir/test/replication_test.exs:1310:19: ReplicationTest.run_continuous_repl/2
```
---
test/elixir/test/replication_test.exs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs
index 09f3e2417..f6658deed 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -1307,7 +1307,7 @@ defmodule ReplicationTest do
is_ddoc = String.starts_with?(doc["_id"], "_design/")
case doc["integer"] do
- N when (N >= 10 and N < 15) or is_ddoc ->
+ n when (n >= 10 and n < 15) or is_ddoc ->
resp = Couch.get!("/#{tgt_db_name}/#{doc["_id"]}")
atts = resp.body["_attachments"]
assert is_map(atts)
(couchdb) 03/07: Prefix unused variables with an underscore
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 39648636d40fd59ac5347067b730090282f26d30
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Fri Aug 16 16:13:18 2024 -0500
Prefix unused variables with an underscore
```
warning: variable "context" is unused (if the variable is not meant to be used, prefix it with an underscore)
│
140 │ test "user-agent header is forbidden", context do
│ ~~~~~~~
│
└─ test/elixir/test/nouveau_test.exs:140:42: NouveauTest."test user-agent header is forbidden"/1
```
---
test/elixir/test/auth_lockout_test.exs | 3 +--
test/elixir/test/basics_test.exs | 2 +-
test/elixir/test/nouveau_test.exs | 8 ++++----
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/test/elixir/test/auth_lockout_test.exs b/test/elixir/test/auth_lockout_test.exs
index fc70c25a9..b039c86eb 100644
--- a/test/elixir/test/auth_lockout_test.exs
+++ b/test/elixir/test/auth_lockout_test.exs
@@ -56,10 +56,9 @@ defmodule AuthLockoutTest do
end
# warning?
- resp = Couch.get("/_all_dbs",
+ _resp = Couch.get("/_all_dbs",
no_auth: true,
headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
)
end
-
end
diff --git a/test/elixir/test/basics_test.exs b/test/elixir/test/basics_test.exs
index 94faf3c2e..3c04ce8a2 100644
--- a/test/elixir/test/basics_test.exs
+++ b/test/elixir/test/basics_test.exs
@@ -383,7 +383,7 @@ defmodule BasicsTest do
end
@tag :with_db
- test "request ID can be specified at the client", context do
+ test "request ID can be specified at the client", _context do
uuid = "E7498DE1-B661-42FA-943D-17F890143068"
resp = Couch.get("/", headers: ["X-Couch-Request-ID": uuid])
assert resp.headers["X-Couch-Request-ID"] == uuid
diff --git a/test/elixir/test/nouveau_test.exs b/test/elixir/test/nouveau_test.exs
index a083755f0..5f97c0aa3 100644
--- a/test/elixir/test/nouveau_test.exs
+++ b/test/elixir/test/nouveau_test.exs
@@ -137,13 +137,13 @@ defmodule NouveauTest do
"status code: #{resp.status_code}, resp body: #{:jiffy.encode(resp.body)}"
end
- test "user-agent header is forbidden", context do
+ test "user-agent header is forbidden", _context do
resp = Couch.get("http://127.0.0.1:5987",
headers: ["User-Agent": "couchdb"])
assert_status_code(resp, 403)
end
- test "search analyze", context do
+ test "search analyze", _context do
url = "/_nouveau_analyze"
resp = Couch.post(url,
headers: ["Content-Type": "application/json"],
@@ -585,7 +585,7 @@ defmodule NouveauTest do
@tag :with_db
test "purge with conflicts", context do
db_name = context[:db_name]
- create_resp = create_conflicted_search_docs(db_name)
+ _create_resp = create_conflicted_search_docs(db_name)
create_ddoc(db_name)
search_url = "/#{db_name}/_design/foo/_nouveau/bar"
@@ -621,7 +621,7 @@ defmodule NouveauTest do
resp = Couch.get(search_url, query: %{q: "*:*", include_docs: true})
assert_status_code(resp, 200)
- hits = Enum.sort(resp.body["hits"])
+ _hits = Enum.sort(resp.body["hits"])
assert get_total_hits(resp) == 2
[hit1, hit2] = Enum.sort(resp.body["hits"])
(couchdb) 01/07: Add `:leex` and `:yecc` to mix.exs
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 27ab0007579c26d62be60fe415126ed4ce52c276
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Mon Dec 30 10:46:22 2024 -0600
Add `:leex` and `:yecc` to mix.exs
Fix warnings when compiling `.xrl` and `.yrl` files.
```
warning: in order to compile .xrl files, you must add "compilers: [:leex] ++ Mix.compilers()" to the "def project" section of couchdbtest's mix.exs
warning: in order to compile .yrl files, you must add "compilers: [:yecc] ++ Mix.compilers()" to the "def project" section of couchdbtest's mix.exs
```
---
mix.exs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mix.exs b/mix.exs
index 236951d6a..5c77f1bbd 100644
--- a/mix.exs
+++ b/mix.exs
@@ -54,7 +54,7 @@ defmodule CouchDBTest.Mixfile do
lockfile: Path.expand("mix.lock", __DIR__),
deps_path: Path.expand("src", __DIR__),
build_path: Path.expand("_build", __DIR__),
- compilers: [:elixir, :app],
+ compilers: [:elixir, :app, :leex, :yecc],
start_permanent: Mix.env() == :prod,
build_embedded: Mix.env() == :prod,
deps: deps(),
(couchdb) 06/07: Fix warnings about operator `===` has no effect
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-elixir-compile-warnings
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit f5f4e8212c775c54c0b275859bbb77ba8fefa999
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Sun Dec 29 23:03:48 2024 -0600
Fix warnings about operator `===` has no effect
```
warning: use of operator === has no effect
│
484 │ retry_resp.status_code in [201, 202]
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ test/elixir/test/design_docs_test.exs:484
```
---
test/elixir/test/design_docs_test.exs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/elixir/test/design_docs_test.exs b/test/elixir/test/design_docs_test.exs
index 09d592b9e..46f12e153 100644
--- a/test/elixir/test/design_docs_test.exs
+++ b/test/elixir/test/design_docs_test.exs
@@ -481,7 +481,7 @@ defmodule DesignDocsTest do
Couch.post("/#{db_name}",
body: ddoc
)
- retry_resp.status_code in [201, 202]
+ assert retry_resp.status_code in [201, 202]
{:ok, _} = create_doc(db_name, %{_id: "doc1", value: 4})
end)
end