You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When capturing a parameter using pattern matching you can either put the parameter name on the left (Param = #{pattern := ToMatch}) or right (#{pattern := ToMatch} = Param) side of the pattern that you use in the function clause. This rule will make sure you are consistent through your code and use always the same style.
Should be on by default?
YES
Options
preferred_style :: left | right (default: left)
Reasoning
Paraphrasing Credo documentation:
When capturing a parameter using pattern matching you can either put the parameter name before or after the value i.e.
parse(#{ok :=Values} =Pair) ->
…
…or…
parse(Pair= #{ok :=Values}) ->
…
Neither of these is better than the other, but it seems a good idea not to mix the two patterns in the same codebase.
While this is not necessarily a concern for the correctness of your code, you should use a consistent style throughout your codebase.
Consistent Param Pattern-Matching
Brief Description
When capturing a parameter using pattern matching you can either put the parameter name on the left (
Param = #{pattern := ToMatch}
) or right (#{pattern := ToMatch} = Param
) side of the pattern that you use in the function clause. This rule will make sure you are consistent through your code and use always the same style.Should be on by default?
YES
Options
preferred_style :: left | right
(default:left
)Reasoning
Paraphrasing Credo documentation:
Origin (#281)
Inspired by the
Consistency.ParameterPatternMatching
rule from CredoThe text was updated successfully, but these errors were encountered: