-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve mod_pubsub test coverage #1241
Conversation
case Affiliation of | ||
owner -> | ||
NewOwner = jid:to_bare(JID), | ||
NewOwners = [NewOwner | Owners], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2721 is too long: NewOwners = [NewOwner | Owners],.
NewOwners = Owners -- [OldOwner], | ||
tree_call(Host, | ||
set_node, | ||
[N#pubsub_node{owners = NewOwners}]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2732 is too long: [N#pubsub_node{owners = NewOwners}]);.
attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] } | ||
|| Unchanged <- Owners ], | ||
AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}], | ||
children = OwnersPayload }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2711 is too long: children = OwnersPayload },.
AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}], | ||
children = OwnersPayload }, | ||
NewPubSubPayload = #xmlel{ name = <<"pubsub">>, attrs = [{<<"xmlns">>, ?NS_PUBSUB_OWNER}], | ||
children = [AffiliationsPayload] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2713 is too long: children = [AffiliationsPayload] },.
@@ -2660,41 +2690,56 @@ set_affiliations(Host, Node, From, EntitiesEls) -> | |||
error -> | |||
{error, ?ERR_BAD_REQUEST}; | |||
_ -> | |||
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O} = N) -> | |||
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O, nodeid = {_, NodeId}} = N) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2693 is too long: Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O, nodeid = {_, NodeId}} = N) ->.
tree_call(Host, | ||
set_node, | ||
[N#pubsub_node{owners = NewOwners}]); | ||
none -> | ||
OldOwner = jid:to_bare(JID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2726 is too long: OldOwner = jid:to_bare(JID),.
{error, {?ERR_NOT_ACCEPTABLE, [NewPubSubPayload]}}; | ||
_ -> | ||
lists:foreach(fun ({JID, Affiliation}) -> | ||
node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2717 is too long: node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]),.
% other invalid affiliation transitions | ||
OwnersDryRun = lists:foldl( | ||
fun({JID, owner}, Acc) -> | ||
sets:add_element(jid:to_bare(JID), Acc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2701 is too long: sets:add_element(jid:to_bare(JID), Acc);.
tree_call(Host, | ||
set_node, | ||
[N#pubsub_node{owners = NewOwners}]); | ||
none -> | ||
OldOwner = jid:to_bare(JID), | ||
case lists:member(OldOwner, Owners) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2727 is too long: case lists:member(OldOwner, Owners) of.
@@ -2876,6 +2924,7 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> | |||
_ -> | |||
[] | |||
end; | |||
%% used by node_flat (therefore by dag, hometree and push as well) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2927 is too long: %% used by node_flat (therefore by dag, hometree and push as well).
case sets:size(OwnersDryRun) of | ||
0 -> | ||
OwnersPayload = [ #xmlel{ name = <<"affiliation">>, | ||
attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2708 is too long: attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] }.
|| Unchanged <- Owners ], | ||
AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}], | ||
children = OwnersPayload }, | ||
NewPubSubPayload = #xmlel{ name = <<"pubsub">>, attrs = [{<<"xmlns">>, ?NS_PUBSUB_OWNER}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2712 is too long: NewPubSubPayload = #xmlel{ name = <<"pubsub">>, attrs = [{<<"xmlns">>, ?NS_PUBSUB_OWNER}],.
OwnersPayload = [ #xmlel{ name = <<"affiliation">>, | ||
attrs = [{<<"jid">>, jid:to_binary(Unchanged)}, {<<"affiliation">>, <<"owner">>}] } | ||
|| Unchanged <- Owners ], | ||
AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2710 is too long: AffiliationsPayload = #xmlel{ name = <<"affiliations">>, attrs = [{<<"node">>, NodeId}],.
({_, none, _}) -> | ||
[]; | ||
%% sometimes used by node_pep | ||
({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubId, SubJID}) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2909 is too long: ({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubId, SubJID}) ->.
node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]), | ||
case Affiliation of | ||
owner -> | ||
NewOwner = jid:to_bare(JID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2720 is too long: NewOwner = jid:to_bare(JID),.
@@ -1526,7 +1556,7 @@ send_pending_auth_events(Request, Host, Node, Owner) -> | |||
send_authorization_request(#pubsub_node{nodeid = {Host, Node}, type = Type, id = Nidx, owners = O}, | |||
Subscriber) -> | |||
Lang = <<"en">>, | |||
Stanza = #xmlel{name = <<"message">>, attrs = [], | |||
Stanza = #xmlel{name = <<"message">>, attrs = [{<<"id">>, list_to_binary(randoms:get_string())}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 1559 is too long: Stanza = #xmlel{name = <<"message">>, attrs = [{<<"id">>, list_to_binary(randoms:get_string())}],.
@@ -1005,6 +1034,8 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) -> | |||
of | |||
{result, IQRes} -> | |||
jlib:iq_to_xml(IQ#iq{type = result, sub_el = IQRes}); | |||
{error, {Error, NewPayload}} -> | |||
jlib:make_error_reply(Packet#xmlel{ children = NewPayload }, Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 1038 is too long: jlib:make_error_reply(Packet#xmlel{ children = NewPayload }, Error);.
@@ -2876,6 +2924,7 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> | |||
_ -> | |||
[] | |||
end; | |||
%% used by node_flat (therefore by dag, hometree and push as well) | |||
({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubJID}) -> | |||
case Node of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
The expression on line 2929 and column 45 is nested beyond the maximum level of 3.
case Affiliation of | ||
owner -> | ||
NewOwner = jid:to_bare(JID), | ||
NewOwners = [NewOwner | Owners], | ||
tree_call(Host, | ||
set_node, | ||
[N#pubsub_node{owners = NewOwners}]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2724 is too long: [N#pubsub_node{owners = NewOwners}]);.
@@ -2660,41 +2690,56 @@ set_affiliations(Host, Node, From, EntitiesEls) -> | |||
error -> | |||
{error, ?ERR_BAD_REQUEST}; | |||
_ -> | |||
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O} = N) -> | |||
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O, nodeid = {_, NodeId}} = N) -> | |||
Owners = node_owners_call(Host, Type, Nidx, O), | |||
case lists:member(Owner, Owners) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
The expression on line 2695 and column 30 is nested beyond the maximum level of 3.
({_, none, _}) -> | ||
[]; | ||
%% sometimes used by node_pep | ||
({#pubsub_node{nodeid = {_, SubsNode}}, Sub, SubId, SubJID}) -> | ||
case Node of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
The expression on line 2910 and column 45 is nested beyond the maximum level of 3.
true -> | ||
NewOwners = Owners -- [OldOwner], | ||
tree_call(Host, | ||
set_node, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2731 is too long: set_node,.
fun({JID, owner}, Acc) -> | ||
sets:add_element(jid:to_bare(JID), Acc); | ||
({JID, _}, Acc) -> | ||
sets:del_element(jid:to_bare(JID), Acc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2703 is too long: sets:del_element(jid:to_bare(JID), Acc).
OldOwner = jid:to_bare(JID), | ||
case lists:member(OldOwner, Owners) of | ||
true -> | ||
NewOwners = Owners -- [OldOwner], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 2729 is too long: NewOwners = Owners -- [OldOwner],.
@@ -3742,11 +3793,12 @@ set_configure(Host, Node, From, Els, Lang) -> | |||
end, | |||
case set_xoption(Host, XData, OldOpts) of | |||
NewOpts when is_list(NewOpts) -> | |||
NewNode = N#pubsub_node{options = NewOpts}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 3796 is too long: NewNode = N#pubsub_node{options = NewOpts},.
@@ -3758,7 +3810,7 @@ set_configure(Host, Node, From, Els, Lang) -> | |||
end | |||
end, | |||
case transaction(Host, Node, Action, transaction) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
The expression on line 3812 and column 21 is nested beyond the maximum level of 3.
d1a225a
to
135ef8e
Compare
135ef8e
to
b46491d
Compare
@@ -3742,11 +3778,12 @@ set_configure(Host, Node, From, Els, Lang) -> | |||
end, | |||
case set_xoption(Host, XData, OldOpts) of | |||
NewOpts when is_list(NewOpts) -> | |||
NewNode = N#pubsub_node{options = NewOpts}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
Line 3781 is too long: NewNode = N#pubsub_node{options = NewOpts},.
@@ -3758,7 +3795,7 @@ set_configure(Host, Node, From, Els, Lang) -> | |||
end | |||
end, | |||
case transaction(Host, Node, Action, transaction) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Elvis:
The expression on line 3797 and column 21 is nested beyond the maximum level of 3.
This is massive coverage improvement! Thanks a lot! |
New PR for rebased+squashed branch