Skip to content
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

Replaced unnecessary map and getOrElse with exists #2035

Closed
wants to merge 4 commits into from

Conversation

Projects
None yet
2 participants
@himani1
Copy link
Contributor

commented Oct 18, 2016

No description provided.

@@ -166,10 +166,10 @@ class SimpleAclAuthorizer extends Authorizer with Logging {
&& (acl.principal == principal || acl.principal == Acl.WildCardPrincipal)
&& (operations == acl.operation || acl.operation == All)
&& (acl.host == host || acl.host == Acl.WildCardHost)
).map { acl: Acl =>
).exists { acl: Acl =>

This comment has been minimized.

Copy link
@hachikuji

hachikuji Oct 18, 2016

Contributor

Kind of annoying that the find uses parenthesis. Maybe fix that too? Also, is the type necessary?

This comment has been minimized.

Copy link
@himani1

himani1 Oct 19, 2016

Author Contributor

@hachikuji I have fixed the parenthesis used with find and removed type.

@@ -160,17 +160,16 @@ class SimpleAclAuthorizer extends Authorizer with Logging {
} else false
}

private def aclMatch(session: Session, operations: Operation, resource: Resource, principal: KafkaPrincipal, host: String, permissionType: PermissionType, acls: Set[Acl]): Boolean = {
private def aclMatch(session: Session, operations: Operation, resource: Resource, principal: KafkaPrincipal, host: String, permissionType: PermissionType, acls: Set[Acl]): Boolean =
acls.find ( acl =>

This comment has been minimized.

Copy link
@hachikuji

hachikuji Oct 19, 2016

Contributor

Did you remove the parenthesis in the wrong place? This is the one I was referring to. I think we should probably keep the braces around the method itself (I usually only remove them if it's a one-liner, but that might be my personal preference).

This comment has been minimized.

Copy link
@himani1

himani1 Oct 19, 2016

Author Contributor

@hachikuji I am not able to understand. find method takes a function, how can I pass function without parenthesis to it ?
def find(p: A => Boolean): Option[A]
Can you please help me out?

This comment has been minimized.

Copy link
@hachikuji

hachikuji Oct 19, 2016

Contributor

Sorry, I was trying to suggest replacing the parenthesis with braces for consistency (somewhat annoyingly, you have to move the && to the previous lines to make it work). It's not a big deal, so if it doesn't actually seem better, feel free to ignore.

This comment has been minimized.

Copy link
@himani1

himani1 Oct 19, 2016

Author Contributor

@hachikuji Ok. I get it now. I have updated with the changes you suggested. Kindly please have a look and let me know if there's some mistake.

@hachikuji

This comment has been minimized.

Copy link
Contributor

commented Oct 19, 2016

LGTM. Thanks for the cleanup!

@asfgit asfgit closed this in 2965f50 Oct 19, 2016

@himani1 himani1 deleted the himani1:code_refactored branch Oct 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.