You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2023/07/12 15:33:32 UTC

[couchdb] branch rebase/access-2023 updated: chore: lint

This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch rebase/access-2023
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/rebase/access-2023 by this push:
     new c432223fe chore: lint
c432223fe is described below

commit c432223fef695d819c1353f82f5298652a86b814
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Wed Jul 12 17:33:23 2023 +0200

    chore: lint
---
 src/couch/src/couch_db.erl                    | 15 ++++++++-------
 src/couch/src/couch_db_updater.erl            | 20 ++++++++++++++------
 src/couch/test/eunit/couchdb_access_tests.erl |  2 +-
 src/couch_mrview/src/couch_mrview_updater.erl |  5 ++++-
 src/couch_mrview/src/couch_mrview_util.erl    |  3 ++-
 src/couch_replicator/src/couch_replicator.erl |  3 ++-
 6 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index ff07aac73..7182defb2 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -842,8 +842,7 @@ check_access(Db, Access) ->
     end.
 
 check_name(null, _Access) -> false;
-check_name(UserName, Access) ->
-    lists:member(UserName, Access).
+check_name(UserName, Access) -> lists:member(UserName, Access).
 
 check_roles(Roles, Access) ->
     UserRolesSet = ordsets:from_list(Roles),
@@ -1580,7 +1579,8 @@ collect_results_with_metrics(Pid, MRef, []) ->
     end.
 
 collect_results(Pid, MRef, ResultsAcc) ->
-    receive % TDOD: need to receiver access?
+    % TDOD: need to receiver access?
+    receive
         {result, Pid, Result} ->
             collect_results(Pid, MRef, [Result | ResultsAcc]);
         {done, Pid} ->
@@ -1600,10 +1600,11 @@ write_and_commit(
     DocBuckets = prepare_doc_summaries(Db, DocBuckets1),
     ReplicatedChanges = lists:member(?REPLICATED_CHANGES, Options),
     MRef = erlang:monitor(process, Pid),
-    UserCtx = case has_access_enabled(Db) of
-        true -> UserCtx0;
-        false -> []
-    end,
+    UserCtx =
+        case has_access_enabled(Db) of
+            true -> UserCtx0;
+            false -> []
+        end,
 
     try
         Pid ! {update_docs, self(), DocBuckets, LocalDocs, ReplicatedChanges, UserCtx},
diff --git a/src/couch/src/couch_db_updater.erl b/src/couch/src/couch_db_updater.erl
index eabb37cd9..4f7c2570b 100644
--- a/src/couch/src/couch_db_updater.erl
+++ b/src/couch/src/couch_db_updater.erl
@@ -284,9 +284,13 @@ maybe_tag_doc(#doc{id = Id, revs = {Pos, [_Rev | PrevRevs]}, meta = Meta0} = Doc
 
 merge_updates([[{_, #doc{id = X}, _} | _] = A | RestA], [[{_, #doc{id = X}, _} | _] = B | RestB]) ->
     [A ++ B | merge_updates(RestA, RestB)];
-merge_updates([[{_, #doc{id = X}, _} | _] | _] = A, [[{_, #doc{id = Y}, _} | _] | _] = B) when X < Y ->
+merge_updates([[{_, #doc{id = X}, _} | _] | _] = A, [[{_, #doc{id = Y}, _} | _] | _] = B) when
+    X < Y
+->
     [hd(A) | merge_updates(tl(A), B)];
-merge_updates([[{_, #doc{id = X}, _} | _] | _] = A, [[{_, #doc{id = Y}, _} | _] | _] = B) when X > Y ->
+merge_updates([[{_, #doc{id = X}, _} | _] | _] = A, [[{_, #doc{id = Y}, _} | _] | _] = B) when
+    X > Y
+->
     [hd(B) | merge_updates(A, tl(B))];
 merge_updates([], RestB) ->
     RestB;
@@ -673,7 +677,6 @@ maybe_stem_full_doc_info(#full_doc_info{rev_tree = Tree} = Info, Limit) ->
             Info
     end.
 
-
 update_docs_int(Db, DocsList, LocalDocs, ReplicatedChanges) ->
     UpdateSeq = couch_db_engine:get_update_seq(Db),
     RevsLimit = couch_db_engine:get_revs_limit(Db),
@@ -747,7 +750,8 @@ update_docs_int(Db, DocsList, LocalDocs, ReplicatedChanges) ->
     % the trees, the attachments are already written to disk)
     {ok, IndexFDIs} = flush_trees(Db, NewFullDocInfos, []),
     Pairs = pair_write_info(OldDocLookups, IndexFDIs),
-    LocalDocs1 = apply_local_docs_access(Db, LocalDocs), % TODO: local docs access needs validating
+    % TODO: local docs access needs validating
+    LocalDocs1 = apply_local_docs_access(Db, LocalDocs),
     LocalDocs2 = update_local_doc_revs(LocalDocs1),
 
     {ok, Db1} = couch_db_engine:write_doc_infos(Db, Pairs, LocalDocs2),
@@ -765,7 +769,10 @@ update_docs_int(Db, DocsList, LocalDocs, ReplicatedChanges) ->
 
     % Check if we just updated any non-access design documents,
     % and update the validation funs if we did.
-    UpdatedDDocIds = [Id || [{_Client, #doc{id = <<"_design/", _/binary>> = Id, access = []}, _} | _] <- DocsList],
+    UpdatedDDocIds = [
+        Id
+     || [{_Client, #doc{id = <<"_design/", _/binary>> = Id, access = []}, _} | _] <- DocsList
+    ],
     {ok, commit_data(Db1), UpdatedDDocIds}.
 
 % at this point, we already validated this Db is access enabled, so do the checks right away.
@@ -820,7 +827,8 @@ validate_docs_access(
     ),
 
     {NewDocsListValidated, NewOldDocInfosValidated} =
-        case length(NewDocs) of %TODO: what if only 2/3?
+        %TODO: what if only 2/3?
+        case length(NewDocs) of
             % we sent out all docs as invalid access, drop the old doc info associated with it
             0 ->
                 {[NewDocs | DocsListValidated], OldDocInfosValidated};
diff --git a/src/couch/test/eunit/couchdb_access_tests.erl b/src/couch/test/eunit/couchdb_access_tests.erl
index 4c4409f60..1f532616d 100644
--- a/src/couch/test/eunit/couchdb_access_tests.erl
+++ b/src/couch/test/eunit/couchdb_access_tests.erl
@@ -134,7 +134,7 @@ access_test_() ->
         % fun should_allow_user_to_replicate_from_no_access_to_access/2,
 
         % fun should_allow_user_to_replicate_from_no_access_to_no_access/2,
- 
+
         % _revs_diff for docs you don’t have access to
         fun should_not_allow_user_to_revs_diff_other_docs/2
 
diff --git a/src/couch_mrview/src/couch_mrview_updater.erl b/src/couch_mrview/src/couch_mrview_updater.erl
index 2afb4e0ab..f147c563f 100644
--- a/src/couch_mrview/src/couch_mrview_updater.erl
+++ b/src/couch_mrview/src/couch_mrview_updater.erl
@@ -174,7 +174,10 @@ map_docs(Parent, #mrst{db_name = DbName, idx_name = IdxName} = State0) ->
             DocFun = fun
                 ({nil, Seq, _}, {SeqAcc, Results}) ->
                     {erlang:max(Seq, SeqAcc), Results};
-                ({Id, Seq, #doc{deleted = true, revs = Rev, body = Body, meta = Meta}}, {SeqAcc, Results}) ->
+                (
+                    {Id, Seq, #doc{deleted = true, revs = Rev, body = Body, meta = Meta}},
+                    {SeqAcc, Results}
+                ) ->
                     % _access needs deleted docs
                     case IdxName of
                         <<"_design/_access">> ->
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index 1795dba35..cd3903ce7 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -441,7 +441,8 @@ reduce_to_count(Reductions) ->
 get_access_row_count(#mrview{btree = Bt}, UserName) ->
     couch_btree:full_reduce_with_options(Bt, [
         {start_key, UserName},
-        {end_key, {[UserName, {[]}]}} % is this correct? should this not be \ufff0?
+        % is this correct? should this not be \ufff0?
+        {end_key, {[UserName, {[]}]}}
     ]).
 
 fold(#mrview{btree = Bt}, Fun, Acc, Opts) ->
diff --git a/src/couch_replicator/src/couch_replicator.erl b/src/couch_replicator/src/couch_replicator.erl
index 98f4e8488..6c2e99e99 100644
--- a/src/couch_replicator/src/couch_replicator.erl
+++ b/src/couch_replicator/src/couch_replicator.erl
@@ -78,7 +78,8 @@ replicate(PostBody, Ctx) ->
         false ->
             check_authorization(RepId, UserCtx),
             {ok, Listener} = rep_result_listener(RepId),
-            Result = % fudge replication id
+            % fudge replication id
+            Result =
                 case do_replication_loop(Rep) of
                     {ok, {ResultJson}} ->
                         % TODO: check with options